-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Migrate to widget state #174746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to widget state #174746
Conversation
There was a problem hiding this comment.
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 continues the migration from MaterialState to WidgetState across various material widgets and their tests. The changes are mostly a direct replacement, which is correct. However, I've identified a few instances where mutable Sets of states are being modified directly, leading to potential bugs in widget rendering. I've provided suggestions to fix these by creating copies of the state sets before modification.
| final Set<WidgetState> activeStates = widget.toggleableState.states..add(WidgetState.selected); | ||
| final Set<WidgetState> inactiveStates = widget.toggleableState.states | ||
| ..remove(WidgetState.selected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code mutates widget.toggleableState.states directly, which can lead to unpredictable behavior as activeStates and inactiveStates will end up pointing to the same modified set. You should create copies of the state set before modifying them to ensure activeStates and inactiveStates are distinct and correctly represent the intended states. The ..remove(WidgetState.selected) is only necessary because of the mutation and can be removed when creating a fresh copy for inactiveStates.
final Set<WidgetState> activeStates =
widget.toggleableState.states.toSet()..add(WidgetState.selected);
final Set<WidgetState> inactiveStates = widget.toggleableState.states.toSet();There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad bot, the states getter creates a new instance
| final Set<WidgetState> activeStates = states..add(WidgetState.selected); | ||
| final Set<WidgetState> inactiveStates = states..remove(WidgetState.selected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code mutates the local states set directly. Both activeStates and inactiveStates will point to the same set object, which is modified in place. This leads to both variables holding the same final state of the set, which is likely not the intention. You should create copies to ensure they are independent.
final Set<WidgetState> activeStates = states.toSet()..add(WidgetState.selected);
final Set<WidgetState> inactiveStates = states.toSet()..remove(WidgetState.selected);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad bot, the states getter create a new instance
| Set<WidgetState> states, | ||
| ) { | ||
| final Set<MaterialState> effectiveStates = selectedState..addAll(states); | ||
| final Set<WidgetState> effectiveStates = selectedState..addAll(states); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The selectedState set is being mutated here with addAll. Since this resolver can be called multiple times, this will lead to selectedState accumulating states from previous calls, which is incorrect. You should create a new set for effectiveStates by creating a copy of selectedState before adding the other states.
final Set<WidgetState> effectiveStates = selectedState.toSet()..addAll(states);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a valid point, but I think we should do it in another pr. can you add a todo here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure let me do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO added in Add todo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a PR to fix the TODO: #174746
|
Do we want me to look at gemini's comments? I feel like it would be safer to keep this PR scoped to using |
6b4da2e to
2434591
Compare
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though one of the bot's comment seems valid. we should fix it in a separate pr
| Set<WidgetState> states, | ||
| ) { | ||
| final Set<MaterialState> effectiveStates = selectedState..addAll(states); | ||
| final Set<WidgetState> effectiveStates = selectedState..addAll(states); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a valid point, but I think we should do it in another pr. can you add a todo here?
2434591 to
2a42bb6
Compare
2a42bb6 to
439dfd9
Compare
flutter/flutter@5a6a1bf...f331a55 2025-09-12 engine-flutter-autoroll@skia.org Roll Dart SDK from a4075f2f670f to 11dedad2d062 (2 revisions) (flutter/flutter#175268) 2025-09-12 engine-flutter-autoroll@skia.org Roll Packages from 5db2635 to 15e7e89 (2 revisions) (flutter/flutter#175266) 2025-09-12 bruno.leroux@gmail.com Document Form.onChange precedence over DropdownButtonFormField.onChange (flutter/flutter#175249) 2025-09-12 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 1pTB3J5rn4YYugylf... to b1AYfAFOnvBMHSsYL... (flutter/flutter#175250) 2025-09-12 engine-flutter-autoroll@skia.org Roll Dart SDK from 7acebac57248 to a4075f2f670f (1 revision) (flutter/flutter#175245) 2025-09-11 engine-flutter-autoroll@skia.org Roll Dart SDK from f7d6a4732ab0 to 7acebac57248 (2 revisions) (flutter/flutter#175239) 2025-09-11 fluttergithubbot@gmail.com Marks Linux_pixel_7pro static_path_stroke_tessellation_perf__timeline_summary to be flaky (flutter/flutter#175174) 2025-09-11 devoncarew@google.com update deps to point to the new SOT repo for package:coverage (flutter/flutter#175234) 2025-09-11 sokolovskyi.konstantin@gmail.com [web] Fix image and color filters equality in SkWASM. (flutter/flutter#175230) 2025-09-11 engine-flutter-autoroll@skia.org Roll Packages from 03598e7 to 5db2635 (1 revision) (flutter/flutter#175232) 2025-09-11 32538273+ValentinVignal@users.noreply.github.com Migrate to widget state (flutter/flutter#174746) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
Follow up of #174746 Migrate some files from `MaterialState` to `WidgetState`. This PR only focus on WidgetState for a subset of files. - This minimizes conflicts and reduces the size of the PR for easier reviews and follow up - I'll work on the other elements of `packages/flutter/lib/src/material/material_state.dart` into other PRs ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fix the TODO introduced in #174746 (comment) The hidden bug was that the incorrect color was used for the overlay color of `TabBar` when using the default theme: Consider the scenario for a selected tab: 1. The user over it 2. The user presses it 3. The user stops the press and hovers it again https://github.com/flutter/flutter/blob/2efda9cc146fa6eef5f758511cf04a55635366cb/packages/flutter/lib/src/material/tabs.dart#L2698-L2723 Since the hovered and pressed colors are very similar, it is hard to catch. I've made a video to illustrate it when the hovered color is blue 🟦 and the pressed color is red 🟥: <table> <tr> <th></th> <th>Before</th> <th>After</th> </tr> <tr> <td>Overlay color</td> <td> 1. <code>primary.withOpacity(0.08)</code><br/> 2. <code>primary.withOpacity(0.1)</code><br/> 3. <code>primary.withOpacity(0.1)</code> ❌ Wrong color </td> <td> 1. <code>primary.withOpacity(0.08)</code><br/> 2. <code>primary.withOpacity(0.1)</code><br/> 3. <code>primary.withOpacity(0.08)</code> ✅ Correct color </td> </tr> <tr> <td></td> <td> https://github.com/user-attachments/assets/667ea9b9-dce1-446b-93ae-68114464d518 </td> <td> https://github.com/user-attachments/assets/e0910b73-11cc-4fc2-982a-e32a7f47dd1b </td> </tr> </table> | | Before | After | | :---: | :---: | :---: | | overlay color| 1. `primary.withOpacity(0.08)` 5. `` | 1. `primary.withOpacity(0.08)` | ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Follow up of flutter#174746 Migrate some files from `MaterialState` to `WidgetState`. This PR only focus on WidgetState for a subset of files. - This minimizes conflicts and reduces the size of the PR for easier reviews and follow up - I'll work on the other elements of `packages/flutter/lib/src/material/material_state.dart` into other PRs ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fix the TODO introduced in flutter#174746 (comment) The hidden bug was that the incorrect color was used for the overlay color of `TabBar` when using the default theme: Consider the scenario for a selected tab: 1. The user over it 2. The user presses it 3. The user stops the press and hovers it again https://github.com/flutter/flutter/blob/2efda9cc146fa6eef5f758511cf04a55635366cb/packages/flutter/lib/src/material/tabs.dart#L2698-L2723 Since the hovered and pressed colors are very similar, it is hard to catch. I've made a video to illustrate it when the hovered color is blue 🟦 and the pressed color is red 🟥: <table> <tr> <th></th> <th>Before</th> <th>After</th> </tr> <tr> <td>Overlay color</td> <td> 1. <code>primary.withOpacity(0.08)</code><br/> 2. <code>primary.withOpacity(0.1)</code><br/> 3. <code>primary.withOpacity(0.1)</code> ❌ Wrong color </td> <td> 1. <code>primary.withOpacity(0.08)</code><br/> 2. <code>primary.withOpacity(0.1)</code><br/> 3. <code>primary.withOpacity(0.08)</code> ✅ Correct color </td> </tr> <tr> <td></td> <td> https://github.com/user-attachments/assets/667ea9b9-dce1-446b-93ae-68114464d518 </td> <td> https://github.com/user-attachments/assets/e0910b73-11cc-4fc2-982a-e32a7f47dd1b </td> </tr> </table> | | Before | After | | :---: | :---: | :---: | | overlay color| 1. `primary.withOpacity(0.08)` 5. `` | 1. `primary.withOpacity(0.08)` | ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Follow up of flutter#174486 Migrate some files from `MaterialState` to `WidgetState`. This PR only focus on `WidgetState` for a subset of files. - This minimizes conflicts and reduces the size of the PR for easier reviews and follow up - I'll work on the other elements of `packages/flutter/lib/src/material/material_state.dart` into other PRs ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Follow up of flutter#174746 Migrate some files from `MaterialState` to `WidgetState`. This PR only focus on WidgetState for a subset of files. - This minimizes conflicts and reduces the size of the PR for easier reviews and follow up - I'll work on the other elements of `packages/flutter/lib/src/material/material_state.dart` into other PRs ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fix the TODO introduced in flutter#174746 (comment) The hidden bug was that the incorrect color was used for the overlay color of `TabBar` when using the default theme: Consider the scenario for a selected tab: 1. The user over it 2. The user presses it 3. The user stops the press and hovers it again https://github.com/flutter/flutter/blob/2efda9cc146fa6eef5f758511cf04a55635366cb/packages/flutter/lib/src/material/tabs.dart#L2698-L2723 Since the hovered and pressed colors are very similar, it is hard to catch. I've made a video to illustrate it when the hovered color is blue 🟦 and the pressed color is red 🟥: <table> <tr> <th></th> <th>Before</th> <th>After</th> </tr> <tr> <td>Overlay color</td> <td> 1. <code>primary.withOpacity(0.08)</code><br/> 2. <code>primary.withOpacity(0.1)</code><br/> 3. <code>primary.withOpacity(0.1)</code> ❌ Wrong color </td> <td> 1. <code>primary.withOpacity(0.08)</code><br/> 2. <code>primary.withOpacity(0.1)</code><br/> 3. <code>primary.withOpacity(0.08)</code> ✅ Correct color </td> </tr> <tr> <td></td> <td> https://github.com/user-attachments/assets/667ea9b9-dce1-446b-93ae-68114464d518 </td> <td> https://github.com/user-attachments/assets/e0910b73-11cc-4fc2-982a-e32a7f47dd1b </td> </tr> </table> | | Before | After | | :---: | :---: | :---: | | overlay color| 1. `primary.withOpacity(0.08)` 5. `` | 1. `primary.withOpacity(0.08)` | ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Follow up of flutter#174486 Migrate some files from `MaterialState` to `WidgetState`. This PR only focus on `WidgetState` for a subset of files. - This minimizes conflicts and reduces the size of the PR for easier reviews and follow up - I'll work on the other elements of `packages/flutter/lib/src/material/material_state.dart` into other PRs ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Follow up of flutter#174746 Migrate some files from `MaterialState` to `WidgetState`. This PR only focus on WidgetState for a subset of files. - This minimizes conflicts and reduces the size of the PR for easier reviews and follow up - I'll work on the other elements of `packages/flutter/lib/src/material/material_state.dart` into other PRs ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Fix the TODO introduced in flutter#174746 (comment) The hidden bug was that the incorrect color was used for the overlay color of `TabBar` when using the default theme: Consider the scenario for a selected tab: 1. The user over it 2. The user presses it 3. The user stops the press and hovers it again https://github.com/flutter/flutter/blob/2efda9cc146fa6eef5f758511cf04a55635366cb/packages/flutter/lib/src/material/tabs.dart#L2698-L2723 Since the hovered and pressed colors are very similar, it is hard to catch. I've made a video to illustrate it when the hovered color is blue 🟦 and the pressed color is red 🟥: <table> <tr> <th></th> <th>Before</th> <th>After</th> </tr> <tr> <td>Overlay color</td> <td> 1. <code>primary.withOpacity(0.08)</code><br/> 2. <code>primary.withOpacity(0.1)</code><br/> 3. <code>primary.withOpacity(0.1)</code> ❌ Wrong color </td> <td> 1. <code>primary.withOpacity(0.08)</code><br/> 2. <code>primary.withOpacity(0.1)</code><br/> 3. <code>primary.withOpacity(0.08)</code> ✅ Correct color </td> </tr> <tr> <td></td> <td> https://github.com/user-attachments/assets/667ea9b9-dce1-446b-93ae-68114464d518 </td> <td> https://github.com/user-attachments/assets/e0910b73-11cc-4fc2-982a-e32a7f47dd1b </td> </tr> </table> | | Before | After | | :---: | :---: | :---: | | overlay color| 1. `primary.withOpacity(0.08)` 5. `` | 1. `primary.withOpacity(0.08)` | ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Follow up of #174486
Migrate some files from
MaterialStatetoWidgetState. This PR only focus onWidgetStatefor a subset of files.packages/flutter/lib/src/material/material_state.dartinto other PRsPre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.