ThexXTURBOXx / flutter_web_auth_2

Flutter plugin for authenticating a user with a web service
https://pub.dev/packages/flutter_web_auth_2
MIT License
51 stars 50 forks source link

WASM Support #112

Closed lucasargento closed 1 month ago

lucasargento commented 3 months ago

Feature Request: WASM Support

The current version of the package depends on dart:html. This makes the new Flutter to WASM compiler break because of compatibility issues. As explained here "Dart has shifted how it enables interop with browser and JavaScript APIs.". The Dart team now provides new, lightweight interop solutions built around static JS interop:

Proposed Solution:

Replace dart:html dependencies (and package:js / dart:js if they exist) by their new counterparts.

Context!

As you might know, Flutter 3.22 release came with WASM at stable and it seems very promising. I would love to test out one of my apps thats currently using Firebase (and depends on flutter_web_auth) with this new compile target. I've tried out building for the web with the WASM flag and received the following error:

`Target dart2wasm failed: ProcessException: Process exited abnormally with exit code 64: NOTE: Compilation to WasmGC is experimental. The support may change, or be removed, with no advance notice.

../../../../.pub-cache/hosted/pub.dev/flutter_web_auth_2-3.1.2/lib/src/web.dart:3:8: Error: Dart library 'dart:html' is not available on this platform. import 'dart:html'; ^ Context: The unavailable library 'dart:html' is imported through these packages:

web_plugin_registrant.dart => package:flutter_web_auth_2 => dart:html

Detailed import paths for (some of) the these imports:

main.dart => web_plugin_registrant.dart => package:flutter_web_auth_2/src/web.dart => dart:html`
ThexXTURBOXx commented 3 months ago

The pre releases for 4.x should be WASM compatible

lishaduck commented 1 month ago

Can you reopen this issue until v4 is stabilized, @lucasargento? I saw it was closed, which was briefly confusing. P.S. Thanks for all your hard work on this library, @ThexXTURBOXx!

ThexXTURBOXx commented 1 month ago

I would like to have issues closed as soon as they are fixed in the master branch. This way, I don't get confused about which issues to address. Since 4.x is close to being stable, it should also not be too bad to still have it this way.

lishaduck commented 1 month ago

I would like to have issues closed as soon as they are fixed in the master branch. This way, I don't get confused about which issues to address.

Ok, fair enough.

4.x is close to being stable

Yay!

it should also not be too bad to still have it this way

I might pin it/edit the issue to say it's in 4.0, but it's not terribly long, so it's probably not going to trip anyone else up 🤷‍♂️