Repository navigation
[material_ui] Remove unconditional dart:io import from about.dart - #12774
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request refactors AboutDialog to remove the unconditional dart:io import, using conditional imports (_about_io.dart and _about_web.dart) to resolve the executable name on web and native platforms. It also adds tests to verify this behavior. The review feedback points out that the test file itself introduces an unconditional dart:io import and accesses Platform.resolvedExecutable, which will cause compilation failures during web testing, and suggests applying conditional imports to the test file as well.
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:async'; | ||
| import 'dart:io' show Platform; |
There was a problem hiding this comment.
Unconditionally importing dart:io in a test file will cause compilation failures when running tests on the web (e.g., via flutter test --platform chrome). Since this PR aims to enable web support, we should avoid unconditional dart:io imports in the test file as well. We can use a conditional import to import the platform-specific executable name helper instead.
| import 'dart:io' show Platform; | |
| import 'package:material_ui/src/_about_io.dart' | |
| if (dart.library.js_interop) 'package:material_ui/src/_about_web.dart' as about; |
There was a problem hiding this comment.
dart:io compiles on the web (it just throws at runtime), so an unconditional import in a test file does not break web test compilation. This file passes with flutter test --platform chrome as-is, and the only test that touches Platform is skipped on the web with skip: kIsWeb. Other tests in this repo (e.g. test/l10n/translations_test.dart) import dart:io the same way. Importing src/_about_io.dart from a test would also couple the test to a private implementation file, so I would prefer to keep the plain import.
| // Regression test for https://github.com/flutter/flutter/issues/191887. | ||
| await tester.pumpWidget(buildWithoutTitle(const AboutDialog())); | ||
|
|
||
| final String expectedName = Platform.resolvedExecutable.split(Platform.pathSeparator).last; |
There was a problem hiding this comment.
Use the conditionally imported about.executableName instead of directly accessing Platform.resolvedExecutable to avoid the compile-time dependency on dart:io on the web.
| final String expectedName = Platform.resolvedExecutable.split(Platform.pathSeparator).last; | |
| final String expectedName = about.executableName; |
There was a problem hiding this comment.
Computing the expected value from Platform.resolvedExecutable directly is intentional: the widget already reads about.executableName, so using the same getter as the expected value would just compare the getter against itself. Deriving it independently keeps the test meaningful. This test is skipped on the web (skip: kIsWeb), so there is no dart:io runtime dependency there.
ddbeab0 to
1bb9871
Compare
| expect(tester.takeException(), isNull); | ||
| expect(find.byType(AboutDialog), findsOneWidget); | ||
| }, | ||
| skip: !kIsWeb, // [intended] Exercises the web-specific fallback. |
There was a problem hiding this comment.
Please add the reduced-web-test-set tag so that this is run on CI.
There was a problem hiding this comment.
Done, added tags: 'reduced-web-test-set' to the web-only test. Verified locally with flutter test --platform chrome --tags reduced-web-test-set test/about_test.dart.
| // file, instead of relying on the default. | ||
| final Title? ancestorTitle = context.findAncestorWidgetOfExactType<Title>(); | ||
| return ancestorTitle?.title ?? Platform.resolvedExecutable.split(Platform.pathSeparator).last; | ||
| return ancestorTitle?.title ?? about.executableName; |
There was a problem hiding this comment.
Please update the corresponding dartdoc comments in AboutDialog, AboutListTile, AdaptiveAboutDialog and LicensePage to specify this resolves to an empty string on web.
There was a problem hiding this comment.
Done. Updated the applicationName docs on AboutListTile, AboutDialog and LicensePage to say it falls back to the file name of Platform.resolvedExecutable on native platforms and to the empty string on the web. AboutDialog.adaptive (_AdaptiveAboutDialog) shares the AboutDialog.applicationName field and its doc, so it is covered by that change too.
| import 'package:flutter/scheduler.dart'; | ||
| import 'package:flutter/widgets.dart' hide Flow; | ||
|
|
||
| import '_about_io.dart' if (dart.library.js_interop) '_about_web.dart' as about; |
There was a problem hiding this comment.
as about is shadowed in this file with variables called about, rename to impl instead (see https://github.com/flutter/flutter/blob/3ea50fa41471c19b8fee694e94b405223545787b/packages/flutter/lib/src/foundation/timeline.dart#L10 for example)
There was a problem hiding this comment.
Done, renamed the prefix to impl.
about.dart imported dart:io only to read Platform.resolvedExecutable as the fallback application name. Because about.dart is reachable from the package barrel, pana marks material_ui as not supporting the web and drops the platform:web and is:wasm-ready tags. Move the lookup behind a conditional import so the web build never references dart:io. Fixes flutter/flutter#191887
- Rename the conditional import prefix from `about` to `impl` so it is not shadowed by the `about` locals in this file. - Document that `applicationName` falls back to the empty string on the web for AboutListTile, AboutDialog (including the adaptive constructor) and LicensePage. - Tag the web-only fallback test with `reduced-web-test-set` so it runs in the web CI shard.
1bb9871 to
f186959
Compare
QuncCccccc
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the fix!
…er#193840) flutter/packages@5620e65...951f2f7 2026-10-05 [email protected] [material_ui] Add scrollPadding property to DropdownMenuFormField (flutter/packages#12735) 2026-10-02 [email protected] [material_ui] Migrate M3 Motion template to use new gen_defaults (flutter/packages#13058) 2026-10-02 [email protected] [cupertino_ui] Forward showDragHandle from showCupertinoSheet to CupertinoSheetRoute (flutter/packages#13011) 2026-10-02 [email protected] [cupertino_ui] Fix CupertinoMagnifier focal point with custom size (flutter/packages#13029) 2026-10-02 [email protected] [ci] Add material_ui and cupertino_ui to customer testing (flutter/packages#13114) 2026-10-02 [email protected] [material_ui] Add Material 3 Expressive migration skill (flutter/packages#12818) 2026-10-02 [email protected] [video_player] Ignore late position updates after disposal (flutter/packages#12971) 2026-10-02 [email protected] [material_ui] Remove unconditional dart:io import from about.dart (flutter/packages#12774) 2026-10-02 [email protected] [material_ui] Fix DropdownButtonFormField underline alignment at bottom (flutter/packages#12606) 2026-10-02 [email protected] Roll Flutter from e89fd0a to d03768e (23 revisions) (flutter/packages#13111) 2026-10-02 [email protected] [material_ui] Migrate `Switch` API doc snippets to {@example} (batch 8) (flutter/packages#13052) 2026-10-02 [email protected] [url_launcher] Fix supportsCloseForLaunchMode to query close support (flutter/packages#12926) 2026-10-02 [email protected] Redistribute iOS/macOS Suggested Reviewers (flutter/packages#13076) 2026-10-02 [email protected] [image_picker] Subsample large images when resizing on Android (flutter/packages#13038) 2026-10-02 [email protected] [cupertino_ui] Remove redundant null arguments in Completer.complete (flutter/packages#13008) 2026-10-02 [email protected] [repo] Update AGENTS.md with dependency allowance and versioning guidance (flutter/packages#12579) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
about.dartimporteddart:iounconditionally, only to readPlatform.resolvedExecutableas the fallback application name when noTitleancestor is found. Becauseabout.dartis reachable from thematerial_uibarrel, pana 0.23.18's static platform analysis marks the whole package as not supporting the web, which drops theplatform:webandis:wasm-readytags on pub.dev. It also means that fallback path throwsUnsupportedErrorwhen it is actually reached on the web.This PR moves the executable-name lookup behind a conditional import (
_about_io.dart/_about_web.dart), following the same patternpackage:flutter's foundation library uses for_platform_io.dart/_platform_web.dart. On the web the fallback name is the empty string, matching the existing empty-string default for the application version. The[Platform.resolvedExecutable]doc references are kept resolvable with a@docImport.Verified locally with pana 0.23.x on this branch:
Supports 6 of 6 possible platforms, and theplatform:web/is:wasm-readytags are back.Fixes flutter/flutter#191887
Pre-Review Checklist
[shared_preferences]///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2