Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support flutter web wasm builds #112

Open
lukepighetti opened this issue Jul 24, 2024 · 3 comments · May be fixed by #114
Open

support flutter web wasm builds #112

lukepighetti opened this issue Jul 24, 2024 · 3 comments · May be fixed by #114
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@lukepighetti
Copy link

lukepighetti commented Jul 24, 2024

Version

4.5.0

Steps to Reproduce

in a flutter web project, build it with flutter build web --wasm

Expected Result

it builds

Actual Result

it doesn't build

More Context

flutter web wasm builds are now in stable branch and it is now a reasonable expectation for packages to support it https://docs.flutter.dev/platform-integration/web/wasm

@lukepighetti lukepighetti added the bug Something isn't working label Jul 24, 2024
@lukepighetti lukepighetti changed the title support wasm builds support flutter web wasm builds Jul 24, 2024
@marandaneto marandaneto added enhancement New feature or request help wanted Extra attention is needed and removed bug Something isn't working labels Jul 25, 2024
@marandaneto
Copy link
Member

marandaneto commented Jul 26, 2024

Thanks for creating the issue.

We'd need to:

Migrate your packages to package:web and dart:js_interop to make them compatible with Wasm. Read the Requires JS-interop section to learn more.

mainly the posthog_flutter_web.dart and posthog_flutter_web_handler.dart files would need to be changed.
Something to check is if after the migration it's still compatible with older Flutter versions (that's a must I'd say otherwise we'd need a major bump).

While we'd like to support it, it's still a low priority since there are a few limitations to running wasm on the browser so we'd not do this right now but soonish, of course PRs are welcome, happy to guide anyway lending a hand here.

@flowhorn
Copy link

flowhorn commented Aug 9, 2024

I tried a little PR, currently I have issues with flutter 3.24 so I couldn't test it again when filing the PR, but this should work using dart:js_interop instead of dart:js.

Feel free to use this PR/adjust it etc.

#114

@marandaneto marandaneto linked a pull request Aug 12, 2024 that will close this issue
4 tasks
@marandaneto
Copy link
Member

I tried a little PR, currently I have issues with flutter 3.24 so I couldn't test it again when filing the PR, but this should work using dart:js_interop instead of dart:js.

Feel free to use this PR/adjust it etc.

#114

a few things have to be fixed such as:

call.arguments['properties'] as Map<Object?, Object?>? ?? {} so the extension jsify is recognized.
For some reason the cast has to be always to Map<Object?, Object?> even though its declared as Map<String, Object>? properties, the method channel is always converting during the invokeMethod call, plus test that everything works as expected, but thanks for the initial PR @flowhorn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants