fix: replace dart:html with conditional imports for cross-platform#15
Open
coder-contrib-bot wants to merge 1 commit into
Open
fix: replace dart:html with conditional imports for cross-platform#15coder-contrib-bot wants to merge 1 commit into
coder-contrib-bot wants to merge 1 commit into
Conversation
…pport dart:html only works on web. This breaks compilation on Android, iOS, Windows, Linux, and macOS. Fixed by splitting into: - print_helper.dart: conditional export (picks web or stub) - print_helper_web.dart: web implementation using dart:html - print_helper_stub.dart: no-op stub for non-web platforms Co-Authored-By: Claude Opus 4.7 (1M context) <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 the
dart:htmlcompilation error on non-web platforms (Android, iOS, Windows, Linux, macOS).Problem:
print_helper.dartdirectly importsdart:htmlwhich is a web-only library. This causes the app to fail compilation on any non-web platform.Solution: Split into conditional imports using Dart's platform-aware export mechanism:
print_helper.dart— conditional export that picks the right implementationprint_helper_web.dart— full web implementation usingdart:html(Blob, URL, window.open)print_helper_stub.dart— no-op stub for non-web platforms (functions exist but do nothing)No changes needed in any file that imports
print_helper.dart— the API surface is identical.Test plan
flutter build webflutter build apkAuthor:
GIT_AUTHOR_NAME=Contrib,GIT_AUTHOR_EMAIL=coder.github.robot@gmail.comThis PR was generated by an AI Agent (Claude Code, Opus 4.7).
🤖 Generated with Claude Code