Repository navigation
[material_ui] Port flutter/flutter #186777 MaterialColor test - #12858
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a new test case to verify MaterialColor swatch comparison and equality. The reviewer suggested formatting the map literals to comply with the 80-character limit and standard dart format rules, and recommended adding an assertion to verify that equal objects produce identical hash codes.
| final sampleMap = <int, Color>{50: const Color(0xFFE1F5FE), 100: const Color(0xFFB3E5FC)}; | ||
| final anotherMap = <int, Color>{50: const Color(0xFFE1F5FE), 100: const Color(0xFFB3E5FC)}; | ||
| final first = MaterialColor(0, sampleMap); | ||
| final second = MaterialColor(0, sampleMap); | ||
| final third = MaterialColor(0, anotherMap); | ||
| expect(first, second); | ||
| expect(first, third); |
There was a problem hiding this comment.
There are two improvements we can make here:
- Formatting: The map initialization lines exceed the 80-character limit and do not adhere to the standard
dart formatformatting rules. Runningdart formatwill automatically wrap these map literals. Formatting them to span multiple lines will ensure style consistency and prevent potential CI formatting check failures. - Test Coverage: When testing custom equality (
operator ==), it is a best practice to also verify that equal objects produce identical hash codes (hashCode). Adding an assertion forhashCodeensures the contract ofoperator ==andhashCodeis fully verified.
final sampleMap = <int, Color>{
50: const Color(0xFFE1F5FE),
100: const Color(0xFFB3E5FC),
};
final anotherMap = <int, Color>{
50: const Color(0xFFE1F5FE),
100: const Color(0xFFB3E5FC),
};
final first = MaterialColor(0, sampleMap);
final second = MaterialColor(0, sampleMap);
final third = MaterialColor(0, anotherMap);
expect(first, second);
expect(first, third);
expect(first.hashCode, third.hashCode);References
- Code should follow the relevant style guides, and use the correct auto-formatter, for each language, as described in the repository contributing guide's Style section. (link)
elliette
left a comment
There was a problem hiding this comment.
Hi @MarlonJD - looks like the analyze step is failing:
info - test/colors_test.dart:88:11 - Omit the type annotation on a local variable when the type is obvious. Try removing the type annotation. - omit_obvious_local_variable_types
info - test/colors_test.dart:92:11 - Omit the type annotation on a local variable when the type is obvious. Try removing the type annotation. - omit_obvious_local_variable_types
Could you please fix? Thanks!
|
autosubmit label was removed for flutter/packages/12858, because This PR has not met approval requirements for merging. Changes were requested by {elliette}, please make the needed changes and resubmit this PR.
|
flutter/packages@1383427...93baed9 2026-10-22 [email protected] [material_ui] Port flutter/flutter flutter#186777 MaterialColor test (flutter/packages#12858) 2026-10-21 [email protected] [rfw] Migrate to material_ui (flutter/packages#12811) 2026-10-21 [email protected] [cupertino_ui] Fix the installing command of the cupertino_ui package (flutter/packages#13141) 2026-10-21 [email protected] [cupertino_ui] Unskip web tests that pass on CanvasKit and Skwasm: date_picker_test, spell_check_suggestions_toolbar_test (flutter/packages#13367) 2026-10-21 [email protected] [video_player] Convert player classes to Swift (flutter/packages#13197) 2026-10-21 [email protected] [camera_windows] Fall back to a physical stream for cameras that reject preferred-stream selectors (flutter/packages#12748) 2026-10-21 [email protected] [google_sign_in_ios, video_player] Specify types for pattern variable declarations (flutter/packages#13362) 2026-10-21 [email protected] [google_maps_flutter_web] Issue 64073 implement my location (flutter/packages#12186) 2026-10-21 [email protected] [material_ui] Unskip web tests that pass on CanvasKit and Skwasm: app_bar_theme_test, input_decorator_test, paginated_data_table_test, spell_check_suggestions_toolbar_test (flutter/packages#13352) 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
flutter/packages@1383427...93baed9 2026-10-22 [email protected] [material_ui] Port flutter/flutter flutter#186777 MaterialColor test (flutter/packages#12858) 2026-10-21 [email protected] [rfw] Migrate to material_ui (flutter/packages#12811) 2026-10-21 [email protected] [cupertino_ui] Fix the installing command of the cupertino_ui package (flutter/packages#13141) 2026-10-21 [email protected] [cupertino_ui] Unskip web tests that pass on CanvasKit and Skwasm: date_picker_test, spell_check_suggestions_toolbar_test (flutter/packages#13367) 2026-10-21 [email protected] [video_player] Convert player classes to Swift (flutter/packages#13197) 2026-10-21 [email protected] [camera_windows] Fall back to a physical stream for cameras that reject preferred-stream selectors (flutter/packages#12748) 2026-10-21 [email protected] [google_sign_in_ios, video_player] Specify types for pattern variable declarations (flutter/packages#13362) 2026-10-21 [email protected] [google_maps_flutter_web] Issue 64073 implement my location (flutter/packages#12186) 2026-10-21 [email protected] [material_ui] Unskip web tests that pass on CanvasKit and Skwasm: app_bar_theme_test, input_decorator_test, paginated_data_table_test, spell_check_suggestions_toolbar_test (flutter/packages#13352) 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
This PR ports the Material-specific test from flutter/flutter#186777 to
material_ui.The
MaterialColor swatch comparisontest verifies equality for separate swatch maps containing the same standardColorvalues.This is a test-only port, so no package version or changelog entry is needed.
Part of flutter/flutter#188444.
The PR that removes the test in the framework is flutter/flutter#192716