Skip to content

fix: replace dart:html with conditional imports for cross-platform#15

Open
coder-contrib-bot wants to merge 1 commit into
mainfrom
claude-code/fix-dart-html-platform/r7t4x2m9
Open

fix: replace dart:html with conditional imports for cross-platform#15
coder-contrib-bot wants to merge 1 commit into
mainfrom
claude-code/fix-dart-html-platform/r7t4x2m9

Conversation

@coder-contrib-bot
Copy link
Copy Markdown
Collaborator

Summary

Fixes the dart:html compilation error on non-web platforms (Android, iOS, Windows, Linux, macOS).

Problem: print_helper.dart directly imports dart:html which 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 implementation
  • print_helper_web.dart — full web implementation using dart: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

  • Verify web build still compiles: flutter build web
  • Verify Android build compiles: flutter build apk
  • Verify print functionality still works on web
  • Verify app doesn't crash on mobile when print is triggered (graceful no-op)

Author: GIT_AUTHOR_NAME=Contrib, GIT_AUTHOR_EMAIL=coder.github.robot@gmail.com

This PR was generated by an AI Agent (Claude Code, Opus 4.7).

🤖 Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant