fix: gate platform implementations on dart.library.io for the Web build - #4
Merged
Merged
Conversation
The conditional exports for ping, connectivity, DNS, port and network capabilities defaulted to the dart:io variants and only switched to the web variants when dart.library.html was defined. Any environment that does not define dart.library.html still resolved the dart:io variants, which pulled dart:io into the Web build. Flip the conditionals so the browser-based variants are the default and the dart:io variants are gated behind dart.library.io. Runtime behaviour on every supported platform is unchanged; only the fallback when neither library is defined becomes dart:io-free.
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 / 摘要
Gate the platform-specific implementations on
dart.library.ioso the Web build no longer resolvesdart:io. / 将各平台实现改为按dart.library.io条件引入,使 Web 构建不再解析到dart:io。Changes / 变更
ping_service.dart,connectivity_service.dart,dns_service.dart,port_service.dartandnetwork_capabilities.dart: the browser-based variants are now the default, and thedart:iovariants are gated behinddart.library.io. / 反转 5 处条件导出:浏览器版本成为默认,dart:io版本改为按dart.library.io命中时启用。pubspec.yaml, both podspecs,README.md,README_zh.mdandCHANGELOG.md. / 版本升级至 1.0.4(pubspec、iOS/macOS podspec、两份 README、CHANGELOG)。Context / 背景
The conditional exports previously defaulted to the
dart:iovariants and only switched to the browser-based variants whendart.library.htmlwas defined. Any environment that does not definedart.library.htmltherefore still resolved thedart:iovariants and pulleddart:iointo the Web build. Making the browser-based variants the default and gating thedart:iovariants behinddart.library.ioleaves the fallbackdart:io-free, while runtime behaviour on every supported platform stays exactly the same. / 此前条件导出默认落到dart:io版本,仅在定义了dart.library.html时切到浏览器版本;未定义该库的环境仍会解析到dart:io版本,从而把dart:io带入 Web 构建。改为浏览器版本兜底、原生版本按dart.library.io引入后,兜底路径不含dart:io,且各平台运行时行为完全不变。Checklist / 检查项
Test plan
dart format --set-exit-if-changed .,flutter analyzeandflutter testall pass locally (49 tests). / 本地格式化校验、静态分析与测试均通过(49 个用例)。🤖 Generated with Zero Buddy