You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make BackgroundIsolateBinaryMessenger API consistent on web #145260
The BackgroundIsolateBinaryMessenger API requires an ensureInitialized() method call before its instance field can be used. Unfortunately the web implementation of the BackgroundIsolateBinaryMessenger does not have the ensureInitialized() method, to the compilation targeted for the web is failing at compile time with Member not found: 'BackgroundIsolateBinaryMessenger.ensureInitialized' error.
Currently we have to make own wrapper with platform-specific import to make this compile on web.
Proposal
It would be really handy if BackgroundIsolateBinaryMessenger has consistent API between io and web implementations. It will be sufficient to have it throw UnsupportedError('Isolates not supported on web.')
@ekuleshov Please check this and see if it helps in your case or not.
Essentially that is the same issue looked from a different angle. But the solution I'm suggesting/requesting here is much simpler and does not require changes in the Dart compiler.
There is already conditional import in the Flutter's package:flutter/services.dart which imports one of:
_background_isolate_binary_messenger_io.dart
_background_isolate_binary_messenger_web.dart
However, due to the asymmetry of the web API (i.e. absence of the ensureInitialized() in the web-specific implementation), in order to use the web version adding if(kIsWeb) ... is not enough as noted in #136886
We have to make own wrapper with our own conditional import and implement own wrappers for ensureInitialized() for io and web.
If the Flutter's _background_isolate_binary_messenger_web.dart implementation simply had an ensureInitialized() method matching the io's API, all of that won't be necessary and we could simply use if(kIsWeb) ... instead of all those custom wrappers.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
darshankawar commentedon Mar 18, 2024
@ekuleshov
Please check this and see if it helps in your case or not.
ekuleshov commentedon Mar 18, 2024
Essentially that is the same issue looked from a different angle. But the solution I'm suggesting/requesting here is much simpler and does not require changes in the Dart compiler.
There is already conditional import in the Flutter's
package:flutter/services.dartwhich imports one of:_background_isolate_binary_messenger_io.dart_background_isolate_binary_messenger_web.dartHowever, due to the asymmetry of the web API (i.e. absence of the
ensureInitialized()in the web-specific implementation), in order to use the web version addingif(kIsWeb) ...is not enough as noted in #136886We have to make own wrapper with our own conditional import and implement own wrappers for
ensureInitialized()for io and web.If the Flutter's
_background_isolate_binary_messenger_web.dartimplementation simply had anensureInitialized()method matching the io's API, all of that won't be necessary and we could simply useif(kIsWeb) ...instead of all those custom wrappers.darshankawar commentedon Mar 19, 2024
Thanks for the feedback.
ditman commentedon Mar 23, 2024
I'll work on adding this method next, it'll
throwUnimplemented (or Unsupported, as requested by OP!)[web] Add BackgroundIsolateBinaryMessenger.ensureInitialized to web. (#…
github-actions commentedon Apr 10, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.