Skip to content

[material_ui] Remove unconditional dart:io import from about.dart - #12774

Merged
auto-submit[bot] merged 2 commits into
flutter:mainfrom
Gyeony95:material-ui-about-dart-io
Oct 2, 2026
Merged

auto-submit[bot] merged 2 commits into
flutter:mainfrom
Gyeony95:material-ui-about-dart-io

Conversation

@Gyeony95

@Gyeony95 Gyeony95 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

about.dart imported dart:io unconditionally, only to read Platform.resolvedExecutable as the fallback application name when no Title ancestor is found. Because about.dart is reachable from the material_ui barrel, pana 0.23.18's static platform analysis marks the whole package as not supporting the web, which drops the platform:web and is:wasm-ready tags on pub.dev. It also means that fallback path throws UnsupportedError when 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 pattern package: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 the platform:web / is:wasm-ready tags are back.

Fixes flutter/flutter#191887

Pre-Review Checklist

Footnotes

  1. 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

@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Sep 7, 2026
@google-cla

google-cla Bot commented Sep 7, 2026

Copy link
Copy Markdown

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Use the conditionally imported about.executableName instead of directly accessing Platform.resolvedExecutable to avoid the compile-time dependency on dart:io on the web.

Suggested change
final String expectedName = Platform.resolvedExecutable.split(Platform.pathSeparator).last;
final String expectedName = about.executableName;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@QuncCccccc QuncCccccc added the CICD Run CI/CD label Sep 10, 2026
@Gyeony95
Gyeony95 force-pushed the material-ui-about-dart-io branch from ddbeab0 to 1bb9871 Compare September 15, 2026 08:41
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 15, 2026
@elliette elliette added the CICD Run CI/CD label Sep 15, 2026
expect(tester.takeException(), isNull);
expect(find.byType(AboutDialog), findsOneWidget);
},
skip: !kIsWeb, // [intended] Exercises the web-specific fallback.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the reduced-web-test-set tag so that this is run on CI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/material_ui/lib/src/about.dart Outdated
// 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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the corresponding dartdoc comments in AboutDialog, AboutListTile, AdaptiveAboutDialog and LicensePage to specify this resolves to an empty string on web.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/material_ui/lib/src/about.dart Outdated
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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@Gyeony95
Gyeony95 force-pushed the material-ui-about-dart-io branch from 1bb9871 to f186959 Compare September 23, 2026 07:43
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 23, 2026
@Gyeony95
Gyeony95 requested a review from elliette September 23, 2026 08:01
@elliette elliette added the CICD Run CI/CD label Sep 30, 2026

@elliette elliette left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, LGTM!

@QuncCccccc QuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the fix!

@QuncCccccc QuncCccccc added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 2, 2026
@auto-submit
auto-submit Bot merged commit 7368361 into flutter:main Oct 2, 2026
14 checks passed
ZhuJHua pushed a commit to ZhuJHua/flutter that referenced this pull request Oct 6, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[material_ui][pana] pana 0.23.18 reports Web as unsupported although the application builds successfully with WebAssembly

3 participants