Repository navigation
[cupertino_ui] Include selectionHandleColor in NoDefaultCupertinoThemeData equality - #13450
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 updates NoDefaultCupertinoThemeData to include selectionHandleColor in its equality and hashCode calculations, and adds a corresponding test and changelog entry. The review feedback suggests moving the new test to the existing NoDefaultCupertinoThemeData equality test block to keep the test suite organized and avoid separating the currentBrightness setup from its group.
| test('NoDefaultCupertinoThemeData equality includes selectionHandleColor', () { | ||
| const red = NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemRed); | ||
| const blue = NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemBlue); | ||
|
|
||
| expect(red, isNot(blue)); | ||
| expect(red, const NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemRed)); | ||
| expect( | ||
| red.hashCode, | ||
| const NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemRed).hashCode, | ||
| ); | ||
| }); |
There was a problem hiding this comment.
This test is placed between currentBrightness = Brightness.light; and group('light colors', ...) which separates the setup of currentBrightness from the group that uses it. Additionally, there is already an existing test block for NoDefaultCupertinoThemeData equality around line 225.\n\nTo keep the test suite organized and maintainable, please remove this test from here and merge its assertions into the existing NoDefaultCupertinoThemeData equality test block at line 225.\n\nHere is how the merged test block at line 225 would look:\n\ndart\n testWidgets('NoDefaultCupertinoThemeData equality', (WidgetTester tester) async {\n const a = NoDefaultCupertinoThemeData();\n final NoDefaultCupertinoThemeData b = a.copyWith();\n final NoDefaultCupertinoThemeData c = a.copyWith(brightness: Brightness.light);\n expect(a, equals(b));\n expect(a, isNot(c));\n\n const red = NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemRed);\n const blue = NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemBlue);\n\n expect(red, isNot(blue));\n expect(red, const NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemRed));\n expect(\n red.hashCode,\n const NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemRed).hashCode,\n );\n });\n
There was a problem hiding this comment.
Thanks, good catch. I moved the assertions into the existing NoDefaultCupertinoThemeData equality test in a21bafe.
2eac1dc to
4fe1103
Compare
theprantadutta
left a comment
There was a problem hiding this comment.
Shouldn't block this PR, but I noticed that removing the hashCode line doesn't cause any tests in theme_test.dart to fail. The hashCode check in this PR compares two identical themes, so it passes even without that line. Could we add a test that specifically verifies the hashCode behavior?
…ashCode The existing assertion only compared the hash codes of two themes with the same color, so it still passed with selectionHandleColor removed from hashCode.
|
Thanks @theprantadutta, good point. The earlier I have also merged |
dkwingsmt
left a comment
There was a problem hiding this comment.
LGTM. Thank you for this fix!
|
Thanks for the review, @dkwingsmt! The presubmits are still waiting on the |
|
Done. Thanks for the reminder. |
| const red = NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemRed); | ||
| const blue = NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemBlue); | ||
| expect(red, isNot(blue)); | ||
| expect(red, const NoDefaultCupertinoThemeData(selectionHandleColor: CupertinoColors.systemRed)); |
There was a problem hiding this comment.
nit: I think the const red values will be canonicalized to the same instance, so == short-circuits and the field checks won't run, and the hashCode check compares an object's hash with itself. Comparing against red.copyWith() (like b at the top of the test) should avoid that.
There was a problem hiding this comment.
Good catch, thanks. Those two were canonicalized to the same instance, so == returned at identical and the hashCode check compared the object with itself. 61c0816 compares red against red.copyWith() instead, so the field comparison and a second hashCode computation both run.
The push removed the CICD label. Could you or @dkwingsmt re-add it so the presubmits can run again?
|
Thanks for re-adding the label, @dkwingsmt. All presubmits are green on the latest commit, which only adds the If this looks good to land, could one of you add the |
|
Thank you @pjkammer and @dkwingsmt for the reviews and for landing this! If either of you happens to have a moment, #13449 is in the same spot this one was: two approvals and up to date with |
…er#196381) flutter/packages@08faf64...653628e 2026-11-11 [email protected] Roll Flutter from fffd8c2 to b98afb5 (31 revisions) (flutter/packages#13623) 2026-11-11 [email protected] [material_ui] Document how to programmatically clear DropdownMenu selection (flutter/packages#13266) 2026-11-11 [email protected] [pigeon] Fix basePath resolution when paths share a string prefix with basePath (flutter/packages#13342) 2026-11-11 [email protected] [cupertino_ui] Fix CupertinoSheetRoute throwing when a drag ends during a pending relayout (flutter/packages#13316) 2026-11-11 [email protected] [shared_preferences] Updates Pigeon to 30.0.1 to support multi-engine registration and deregistration. (flutter/packages#13617) 2026-11-11 [email protected] [vector_graphics] Catch any throwable in useHtmlRenderObject() and cache HTML fallback (flutter/packages#13545) 2026-11-11 [email protected] [cupertino_ui] Include selectionHandleColor in NoDefaultCupertinoThemeData equality (flutter/packages#13450) 2026-11-11 [email protected] [flutter_svg] Remove failed async loads from Cache._pending (flutter/packages#13604) 2026-11-11 [email protected] [pigeon] Adds Native Interop FFI codec serialization for NS types (flutter/packages#13616) 2026-11-10 [email protected] [pigeon] Support multi-engine Native Interop registration and instance-aware unregistration (flutter/packages#13576) 2026-11-10 [email protected] [image_picker_ios] Convert the iOS example app and UI tests to Swift (flutter/packages#13570) 2026-11-10 [email protected] [cupertino_ui] Localize CupertinoActionSheet semantics label (flutter/packages#13377) 2026-11-10 [email protected] [camera_android] Fix stopVideoRecording returning JPEG when takePicture runs during recording (flutter/packages#13070) 2026-11-10 [email protected] [google_sign_in_android] Rename keep.xml to google_sign_in_keep.xml (flutter/packages#13475) 2026-11-10 [email protected] [web_benchmarks] Fix benchmark stalling when only repainting views that are dirty (flutter/packages#13089) 2026-11-10 [email protected] Roll Flutter from d463821 to fffd8c2 (21 revisions) (flutter/packages#13614) 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
NoDefaultCupertinoThemeData.operator ==andhashCodeleave outselectionHandleColor, so two themes that differ only in that color compare equal.CupertinoThemeData, which extends it, already includes the field. BecauseThemeData ==comparescupertinoOverrideTheme, an app that passes aNoDefaultCupertinoThemeDatathere and changes only itsselectionHandleColorgets an "equal"ThemeData, and dependents aren't rebuilt.This adds the field to both methods, matching
CupertinoThemeData, and adds a unit test.Fixes flutter/flutter#195391
Pre-Review Checklist
[shared_preferences]///).