Skip to content

[cupertino_ui] Include selectionHandleColor in NoDefaultCupertinoThemeData equality - #13450

Merged
auto-submit[bot] merged 7 commits into
flutter:mainfrom
ChandraChaan:cupertino-ui-nodefault-theme-selection-handle-color
Nov 11, 2026
Merged

auto-submit[bot] merged 7 commits into
flutter:mainfrom
ChandraChaan:cupertino-ui-nodefault-theme-selection-handle-color

Conversation

@ChandraChaan

Copy link
Copy Markdown
Contributor

NoDefaultCupertinoThemeData.operator == and hashCode leave out selectionHandleColor, so two themes that differ only in that color compare equal. CupertinoThemeData, which extends it, already includes the field. Because ThemeData == compares cupertinoOverrideTheme, an app that passes a NoDefaultCupertinoThemeData there and changes only its selectionHandleColor gets 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

@google-cla

google-cla Bot commented Oct 27, 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.

@github-actions github-actions Bot added p: cupertino_ui triage-design Should be looked at in design triage labels Oct 27, 2026

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

Comment on lines +286 to +296
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,
);
});

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.

medium

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

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.

Thanks, good catch. I moved the assertions into the existing NoDefaultCupertinoThemeData equality test in a21bafe.

@ChandraChaan
ChandraChaan force-pushed the cupertino-ui-nodefault-theme-selection-handle-color branch from 2eac1dc to 4fe1103 Compare October 27, 2026 04:16
@elliette
elliette requested a review from dkwingsmt October 27, 2026 21:19

@theprantadutta theprantadutta 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.

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?

ChandraChaan and others added 2 commits November 8, 2026 20:04
…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.
@ChandraChaan

Copy link
Copy Markdown
Contributor Author

Thanks @theprantadutta, good point. The earlier hashCode assertion compared two equal themes, so it passed with or without the new line. e2b925b adds expect(red.hashCode, isNot(blue.hashCode)), where red and blue differ only in selectionHandleColor, so the test now fails if selectionHandleColor is dropped from hashCode.

I have also merged main into the branch to pick up the tool test fix from #13544.

@dkwingsmt dkwingsmt 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. Thank you for this fix!

@dkwingsmt
dkwingsmt requested a review from pjkammer November 10, 2026 05:53
@dkwingsmt dkwingsmt added the CICD Run CI/CD label Nov 10, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 10, 2026
@ChandraChaan

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @dkwingsmt! The presubmits are still waiting on the CICD label. Could you add it when you get a chance so they can run?

@dkwingsmt dkwingsmt added the CICD Run CI/CD label Nov 10, 2026
@dkwingsmt

Copy link
Copy Markdown
Contributor

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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

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.

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?

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 11, 2026
@dkwingsmt dkwingsmt added the CICD Run CI/CD label Nov 11, 2026
@ChandraChaan

Copy link
Copy Markdown
Contributor Author

Thanks for re-adding the label, @dkwingsmt. All presubmits are green on the latest commit, which only adds the red.copyWith() comparison @pjkammer suggested and a merge of main.

If this looks good to land, could one of you add the autosubmit label? I do not have permission to add it myself.

@pjkammer pjkammer added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 11, 2026
@auto-submit
auto-submit Bot merged commit b762b3f into flutter:main Nov 11, 2026
13 checks passed
@ChandraChaan

Copy link
Copy Markdown
Contributor Author

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 main, but the presubmits cannot start until the CICD label is re-added. No worries if it is outside your area.

opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-flutter__flutter that referenced this pull request Nov 11, 2026
…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
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: cupertino_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cupertino_ui] NoDefaultCupertinoThemeData == and hashCode ignore selectionHandleColor

4 participants