Search code examples
flutterdartwebassembly

kIsWasm always return false / How to compile for WebAssembly support?


Following the official Flutter Wasm documentation (https://docs.flutter.dev/platform-integration/web/wasm) I tried to compile my Flutter Web App for Wasm-support, but constant kIsWasm returns always false.

I used Text(kIsWasm ? 'WebAssembly active' : 'WebAssembly inactive') on my initial Screen to find this out.

What I did already:

  1. I use Flutter stable channel on version 3.22.3
  2. To make sure there is no problem inside my index.html I deleted the "web"-folder and recreated it with: flutter create . --platforms=web
  3. flutter build web --wasm compiles successfully: "✓ Built build/web"
  4. Directly after that I start a local server in my "build/web"-folder with dhttp for testing purpose to make sure it is no server side cross origin problem: dhttpd '--headers=Cross-Origin-Embedder-Policy=credentialless;Cross-Origin-Opener-Policy=same-origin'
  5. I use Chrome version 126 to open localhost:8080, so it should be no browser incompatibility, but kIsWasm is still false.

Any ideas what I may be doing wrong or what is missing?


Solution

  • This is a flutter bug which is fixed on the main/master channel 3.24.0-1.0.pre.214 already. https://github.com/flutter/flutter/issues/152089