Flutter build web failing due to EventStreamProviders
(editor update: see below - we've reverted the 2.4.2 publish of this package).
While running flutter build web the following error comes up, until yesterday the builds are working properly. The new update on web_socket_channel:2.4.2 affected this error. We are not using this package directly but some of the packages are dependent on it.
ERROR LOGS :
../../../../.pub-cache/hosted/pub.dev/web_socket_channel-2.4.2/lib/src/web_helpers.dart:10:32:
Error: The getter 'EventStreamProviders' isn't defined for the class 'WebSocket'.
- 'WebSocket' is from 'package:web/src/dom/websockets.dart' ('../../../../.pub-cache/hosted/pub.dev/web-0.3.0/lib/src/dom/websockets.dart').
Stream<Event> get onOpenX => EventStreamProviders.openEvent.forTarget(this);
^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/web_socket_channel-2.4.2/lib/src/web_helpers.dart:12:7:
Error: The getter 'EventStreamProviders' isn't defined for the class 'WebSocket'.
- 'WebSocket' is from 'package:web/src/dom/websockets.dart' ('../../../../.pub-cache/hosted/pub.dev/web-0.3.0/lib/src/dom/websockets.dart').
EventStreamProviders.messageEvent.forTarget(this);
^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/web_socket_channel-2.4.2/lib/src/web_helpers.dart:14:7:
Error: The getter 'EventStreamProviders' isn't defined for the class 'WebSocket'.
- 'WebSocket' is from 'package:web/src/dom/websockets.dart' ('../../../../.pub-cache/hosted/pub.dev/web-0.3.0/lib/src/dom/websockets.dart').
EventStreamProviders.closeEvent.forTarget(this);
^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/web_socket_channel-2.4.2/lib/src/web_helpers.dart:16:7:
Error: The getter 'EventStreamProviders' isn't defined for the class 'WebSocket'.
- 'WebSocket' is from 'package:web/src/dom/websockets.dart' ('../../../../.pub-cache/hosted/pub.dev/web-0.3.0/lib/src/dom/websockets.dart').
EventStreamProviders.errorEventSourceEvent.forTarget(this);
^^^^^^^^^^^^^^^^^^^^
Same here
Palliative solution: dependency_overrides: web_socket_channel: 2.4.0
https://github.com/dart-lang/web_socket_channel/issues/316
Palliative solution: dependency_overrides: web_socket_channel: 2.4.0
dart-lang/web_socket_channel#316
Good!
Hi - these most recent issues were likely caused by the release of 2.4.2, which adjusted the dep on package:web in ways that weren't compatible. We're retracted that release - people who have it pinned explicitly will still see it, but it won't be visible to new version solves.
Also, it looks porting this package to use package:web was (unintentionally) a breaking API change - some of the API types exposed from the package are different. We'll track work to address that in a separate issue, but we may revert the 2.4.x range of this package back to using dart:html, and publishing a new 3.0.0 version of this package that's based on package:web.
dart-lang/http#1655 becomes relevant again because 2.4.3 is once-again reliant on pkg:web 0.4.0 or higher, and Flutter has 0.3.0 pinned. Flutter still won't be able to use 2.4.3.
This is the same situation for other packages that Flutter pins however. You need to use dependencies that are compatible with the versions that Flutter was built with. For package:web, that's:
- stable - pinned
webto0.3.0 - beta - pinned
webto0.4.0 - main - the pin's been removed; the few uses of package:web were in-lined into the framework