Sitelet https://github.com/flutter/flutter/pull/191380
Skip to content

Refactor splash example to not use material_ui - #191380

Open
GhagSagar23 wants to merge 9 commits into
flutter:masterfrom
GhagSagar23:fix/190305-minimize-cross-imports-in-examples
Open

GhagSagar23 wants to merge 9 commits into
flutter:masterfrom
GhagSagar23:fix/190305-minimize-cross-imports-in-examples

Conversation

@GhagSagar23

Copy link
Copy Markdown
Contributor

Converts examples/splash to widgets-only so it no longer cross-imports the Material layer.

splash pulled in package:material_ui/material_ui.dart for exactly two symbols: Colors.white and Colors.black87. Everything else it renders — DecoratedBox, BoxDecoration, Center, Column, Padding, Text, TextStyle, FlutterLogo — is already exported by package:flutter/widgets.dart (FlutterLogo at packages/flutter/lib/widgets.dart:59). Replacing those two colours with local Color constants drops the dependency with no change to the rendered output.

This follows the examples/flutter_view conversion in #190377 — local const Color declarations at the top of main.dart. splash needs no WidgetsApp because it never had a MaterialApp, which is what makes it the smallest self-contained unit to start with.

Changes

  • examples/splash/lib/main.dart — import package:flutter/widgets.dart; add const Color _white = Color(0xFFFFFFFF) and const Color _black87 = Color(0xDD000000) (values taken from packages/flutter/lib/src/material/colors.dart:396 and :310) and use them in place of Colors.white / Colors.black87. The widget tree, sizes, padding and text are otherwise unchanged.
  • examples/splash/test/splash_test.dart — same import swap, moved above flutter_test to satisfy directives_ordering. The existing Displays flutter logo and message test is untouched. Adds one test pinning the two colour values, since swapping Colors.* for literals is the one way this refactor could silently change rendering.
  • examples/splash/pubspec.yaml — remove material_ui: ^0.0.2 and update the # PUBSPEC CHECKSUM: line.

pubspec.lock is deliberately unchanged: material_ui is still a direct dependency of image_list, layers, multiple_windows, platform_channel, platform_channel_swift and platform_view, so its root lock entry is still required.

Scope

This is one example, not the whole issue. 27 package:material_ui imports remain across those six examples, and examples/texture/lib/main.dart is still on package:flutter/material.dart — the only examples/ entry left in knownExamplesCrossImports. Note that removing that one also means deleting its allowlist line in the same commit, since the checker fails when a known cross import disappears. Happy to take the rest in follow-ups if the shape here looks right to you.

One thing worth flagging

dev/bots/check_examples_cross_imports.dart does not catch any of these. LibraryCrossImportStatementType in dev/bots/cross_imports_checker_utils.dart matches only the literal strings import 'package:flutter/material.dart' and import 'package:flutter/cupertino.dart', so material_ui / cupertino_ui imports are invisible to the cross-imports-examples validation today — anything cleaned up can regress silently. I have not touched the checker here. Whether it should learn about the package imports, and whether that lands before or after the conversions, seems like your call rather than something to fold into a cleanup PR — the utils file is shared with check_tests_cross_imports.dart, so it is not a mechanical change.

Part of #190305
Part of #177028

Pre-launch Checklist


NOT PART OF THE PR BODY — author pre-flight (delete before posting)

Nothing above the separator has been published. The diff is uncommitted on branch fix/190305-minimize-cross-imports-in-examples in workspaces/flutter__flutter__issue-190305. Three things must happen before this is opened:

1. Post the claim comment and get a reply first. #190305 was filed by justinmc (Flutter team) under team-framework / P2 as part of #177028, with no good first issue or help wanted label, and the team is actively landing adjacent PRs (#190237, #190248, #190377). The assessment sets maintainer_alignment_required: true. The drafted claim comment in reports/flutter__flutter__190305/assessment.json is unposted. Sending an unsolicited PR into in-flight team work is the main risk here, not the code.

2. Run the tests. None have been run. Docker is permission-gated in this pipeline, so every command below is unexecuted and the checklist boxes above are all unchecked for that reason. Run these in the configured runner (ghcr.io/cirruslabs/flutter:stable), then tick the boxes:

python3 scripts/safe_project.py --workspace workspaces/flutter__flutter__issue-190305 --stack flutter --image ghcr.io/cirruslabs/flutter:stable --network on  -- bin/flutter update-packages
python3 scripts/safe_project.py --workspace workspaces/flutter__flutter__issue-190305 --stack flutter --image ghcr.io/cirruslabs/flutter:stable --network off -- bin/flutter test examples/splash
python3 scripts/safe_project.py --workspace workspaces/flutter__flutter__issue-190305 --stack flutter --image ghcr.io/cirruslabs/flutter:stable --network off -- bin/flutter analyze --no-pub examples/splash
python3 scripts/safe_project.py --workspace workspaces/flutter__flutter__issue-190305 --stack flutter --image ghcr.io/cirruslabs/flutter:stable --network off -- bin/cache/dart-sdk/bin/dart format --output=none --set-exit-if-changed examples/splash
python3 scripts/safe_project.py --workspace workspaces/flutter__flutter__issue-190305 --stack flutter --image ghcr.io/cirruslabs/flutter:stable --network off -- bin/cache/dart-sdk/bin/dart --enable-asserts dev/bots/check_examples_cross_imports.dart

3. Settle the checksum. # PUBSPEC CHECKSUM: 60tfp7 was derived by inference, not generated by the tool. _computeChecksum (packages/flutter_tools/lib/src/commands/update_packages.dart:535) hashes only the sorted dependency map, and splash's post-change set (flutter + flutter_test) is now byte-identical to dev/manual_tests and dev/benchmarks/imitation_game_flutter, both of which carry 60tfp7 — verified in-tree. bin/flutter update-packages confirms it in one run; if it reports a mismatch, rerun with --update-hashes and take the corrected line.

Open items for the author

  • The second test is optional. The orchestrator asked for regression coverage; acceptance criterion 3 asked for an import-line-only change to the test file. Both were honoured by adding a test rather than editing the existing one. Drop the Uses the original splash palette block if maintainers prefer the minimal diff. It relies on find.byType(DecoratedBox).first being the app background — correct because FlutterLogo builds its own DecoratedBox via AnimatedContainer (packages/flutter/lib/src/widgets/flutter_logo.dart:72-77) as a descendant, and finders traverse in pre-order — but this is a static argument, not an observed pass.
  • material_ui was not read directly. It is an external pub package (^0.0.2); Colors.white / Colors.black87 were verified against the repo's own packages/flutter/lib/src/material/colors.dart, not the package source, which lives outside the workspace.
  • This partially walks back Migrate examples/splash to package:material_ui #190248 (Migrate examples/splash to package:material_ui), which is the intended direction per Minimize cross imports in examples #190305 but worth naming if a reviewer asks why splash changed twice.
  • Precedent attribution: the conversion pattern comes from Refactor flutter_view example to not use material #190377 (Refactor flutter_view example to not use material). Migrate layers example to material_ui #190237 is the layers migration whose review thread prompted the issue — they are different PRs.

@github-actions github-actions Bot added the d: examples Sample code and demos label Aug 19, 2026
@GhagSagar23
GhagSagar23 marked this pull request as ready for review August 21, 2026 11:51

@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 removes the dependency on the material_ui package from the splash example, replacing its imports and color usages with flutter/widgets.dart and local color constants. It also adds a new widget test to verify the splash palette. Feedback on the test indicates that await tester.pump() should be called after entrypoint.main() to ensure the scheduled frame is executed and the widgets are built before assertions are made.

Comment thread examples/splash/test/splash_test.dart
navaronbracke
navaronbracke previously approved these changes Aug 28, 2026

@navaronbracke navaronbracke 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 with nit

Comment thread examples/splash/lib/main.dart Outdated
@GhagSagar23
GhagSagar23 force-pushed the fix/190305-minimize-cross-imports-in-examples branch from 8a66553 to f960378 Compare August 28, 2026 20:06
navaronbracke
navaronbracke previously approved these changes Aug 28, 2026
@navaronbracke navaronbracke added the CICD Run CI/CD label Aug 28, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 30, 2026
@Piinks Piinks added the framework flutter/packages/flutter repository. See also f: labels. label Sep 2, 2026
@Renzo-Olivares
Renzo-Olivares self-requested a review September 8, 2026 22:32
@github-actions github-actions Bot removed the framework flutter/packages/flutter repository. See also f: labels. label Sep 13, 2026
@Piinks
Piinks dismissed navaronbracke’s stale review September 22, 2026 14:56

We migrated this to material_ui intentionally.

@Renzo-Olivares Renzo-Olivares 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.

Hi @GhagSagar23, thank you for the contribution. Just had a small comment but otherwise LGTM.

// The outermost DecoratedBox is the app background; FlutterLogo builds one
// of its own further down the tree.
final background = tester.widget<DecoratedBox>(find.byType(DecoratedBox).first);
expect(background.decoration, const BoxDecoration(color: Color(0xFFFFFFFF)));

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.

nit: It would be better if the color used here taken directly from the example like a constant. In case someone decides to change the colors the test won't diverge. Same for message.style?.color below.

expect(background.decoration, const BoxDecoration(color: _splashColor)); or similar.

Also can this be

expect(background.decoration.color, _splashColor);

@Renzo-Olivares Renzo-Olivares added the waiting for response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

d: examples Sample code and demos waiting for response The Flutter team cannot make further progress on this issue until the original reporter responds

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants