0

I'm developing a Flutter project targeting both mobile and web platforms. I want to build most of the app using WebAssembly (Wasm) for performance. However, the google_maps_flutter package doesn't support Wasm, which causes build issues.

I tried building the entire project with Wasm, but google_maps_flutter caused errors. I expected to find a way to use Wasm for the compatible parts of the app while excluding google_maps_flutter from the Wasm build. Is there a way to conditionally build the app using Wasm for supported components and use google_maps_flutter as normal for the web?

1 Answer 1

1

You may use conditional imports and/or specific platform checks.

Something like:

import 'map.dart'
  if (dart.library.html) 'map__wasm.dart'
  if (dart.library.io) 'map_native.dart';

and:

if (kIsWeb) {...}

See also

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for response! The code compiles this way, but it currently doesn't include the map functionality on the web. I want to use 'google_maps_flutter' on the web and compile everything else using Wasm. Is there a way to achieve this, where everything except google_maps_flutter is compiled with Wasm, and the map functionality is included when running on the web?
@GigaAnanidze I'm currently unsure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.