Repository navigation
Refactor splash example to not use material_ui - #191380
GhagSagar23 wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
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.
8a66553 to
f960378
Compare
We migrated this to material_ui intentionally.
Renzo-Olivares
left a comment
There was a problem hiding this comment.
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))); |
There was a problem hiding this comment.
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);
Converts
examples/splashto widgets-only so it no longer cross-imports the Material layer.splashpulled inpackage:material_ui/material_ui.dartfor exactly two symbols:Colors.whiteandColors.black87. Everything else it renders —DecoratedBox,BoxDecoration,Center,Column,Padding,Text,TextStyle,FlutterLogo— is already exported bypackage:flutter/widgets.dart(FlutterLogoatpackages/flutter/lib/widgets.dart:59). Replacing those two colours with localColorconstants drops the dependency with no change to the rendered output.This follows the
examples/flutter_viewconversion in #190377 — localconst Colordeclarations at the top ofmain.dart.splashneeds noWidgetsAppbecause it never had aMaterialApp, which is what makes it the smallest self-contained unit to start with.Changes
examples/splash/lib/main.dart— importpackage:flutter/widgets.dart; addconst Color _white = Color(0xFFFFFFFF)andconst Color _black87 = Color(0xDD000000)(values taken frompackages/flutter/lib/src/material/colors.dart:396and:310) and use them in place ofColors.white/Colors.black87. The widget tree, sizes, padding and text are otherwise unchanged.examples/splash/test/splash_test.dart— same import swap, moved aboveflutter_testto satisfydirectives_ordering. The existingDisplays flutter logo and messagetest is untouched. Adds one test pinning the two colour values, since swappingColors.*for literals is the one way this refactor could silently change rendering.examples/splash/pubspec.yaml— removematerial_ui: ^0.0.2and update the# PUBSPEC CHECKSUM:line.pubspec.lockis deliberately unchanged:material_uiis still a direct dependency ofimage_list,layers,multiple_windows,platform_channel,platform_channel_swiftandplatform_view, so its root lock entry is still required.Scope
This is one example, not the whole issue. 27
package:material_uiimports remain across those six examples, andexamples/texture/lib/main.dartis still onpackage:flutter/material.dart— the onlyexamples/entry left inknownExamplesCrossImports. 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.dartdoes not catch any of these.LibraryCrossImportStatementTypeindev/bots/cross_imports_checker_utils.dartmatches only the literal stringsimport 'package:flutter/material.dart'andimport 'package:flutter/cupertino.dart', somaterial_ui/cupertino_uiimports are invisible to thecross-imports-examplesvalidation 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 withcheck_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-examplesinworkspaces/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/P2as part of #177028, with nogood first issueorhelp wantedlabel, and the team is actively landing adjacent PRs (#190237, #190248, #190377). The assessment setsmaintainer_alignment_required: true. The drafted claim comment inreports/flutter__flutter__190305/assessment.jsonis 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:3. Settle the checksum.
# PUBSPEC CHECKSUM: 60tfp7was 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 todev/manual_testsanddev/benchmarks/imitation_game_flutter, both of which carry60tfp7— verified in-tree.bin/flutter update-packagesconfirms it in one run; if it reports a mismatch, rerun with--update-hashesand take the corrected line.Open items for the author
Uses the original splash paletteblock if maintainers prefer the minimal diff. It relies onfind.byType(DecoratedBox).firstbeing the app background — correct becauseFlutterLogobuilds its ownDecoratedBoxviaAnimatedContainer(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_uiwas not read directly. It is an external pub package (^0.0.2);Colors.white/Colors.black87were verified against the repo's ownpackages/flutter/lib/src/material/colors.dart, not the package source, which lives outside the workspace.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.flutter_viewexample to not usematerial#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.