Repository navigation
Conversation
The web PlatformService and StatusBarService were selected with 'if (dart.library.js)', which is false under dart2wasm. A WASM build therefore used the mobile services, and on a mobile browser called the status bar plugin, which has no web implementation. Select the status bar service with 'if (dart.library.io)' instead, and make PlatformService a single kIsWeb-aware implementation based on defaultTargetPlatform, which also removes the universal_io dependency that made pub.dev mark the package as not WASM compatible. Refs Stacked-Org/stacked#1105 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
stacked_themeson WebAssembly builds and makes it WASM compatible on pub.dev. Refs Stacked-Org/stacked#1105.Problems
Wrong services under WASM. The web versions of
PlatformServiceandStatusBarServicewere chosen withif (dart.library.js). That condition is false under dart2wasm, so a WASM build used the mobile services. On a mobile browser the mobilePlatformServicereports Android or iOS, and themes then calls theflutter_statusbarcolor_nsplugin, which has no web implementation.Reproduced with
flutter build web --wasm, an Android user agent, and aThemeBuilderwithstatusBarColorBuilder:thrown uncaught on every theme change. The JavaScript build is not affected.
Not WASM compatible on pub.dev.
platform_service.dartimportsuniversal_io, which resolves to a file importingdart:iounder the wasm runtime. The latestuniversal_iois itself not WASM ready.Change
StatusBarService: default to the web stub and pick the plugin-backed one withif (dart.library.io). That is false for both JavaScript and WASM web builds and works on every Dart version this package supports.PlatformService: one implementation usingkIsWebanddefaultTargetPlatform. Web still reportsfalseforisIosandisAndroid, as the old web file did.platform_service_web.dartis removed.pubspec.yaml: removeuniversal_io.No public API change. Mobile behaviour is unchanged.
Verification
.wasmmodule with no JS fallback.panaon this branch:is:wasm-ready, platform support 20/20. Onmainit is not.flutter test: 24 passed.flutter analyze: only the existingwindowdeprecation info.dart format: clean.Note: this PR comes from a fork, so the coverage comment step may fail with "Resource not accessible by integration". Format, analyze and test are the steps that matter.
🤖 Generated with Claude Code