这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@ValentinVignal
Copy link
Contributor

Follow up of #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

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

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. labels Aug 30, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines +672 to +674
final Set<WidgetState> activeStates = widget.toggleableState.states..add(WidgetState.selected);
final Set<WidgetState> inactiveStates = widget.toggleableState.states
..remove(WidgetState.selected);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

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

Copy link
Contributor

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

Comment on lines +958 to +959
final Set<WidgetState> activeStates = states..add(WidgetState.selected);
final Set<WidgetState> inactiveStates = states..remove(WidgetState.selected);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

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

Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

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

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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

@ValentinVignal
Copy link
Contributor Author

Do we want me to look at gemini's comments? I feel like it would be safer to keep this PR scoped to using WidgetState without any logic changes

@ValentinVignal ValentinVignal force-pushed the flutter/migrate-to-widget-state/3 branch from 6b4da2e to 2434591 Compare September 2, 2025 07:33
Copy link
Contributor

@chunhtai chunhtai left a 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);
Copy link
Contributor

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?

@ValentinVignal ValentinVignal force-pushed the flutter/migrate-to-widget-state/3 branch from 2434591 to 2a42bb6 Compare September 4, 2025 06:30
@ValentinVignal ValentinVignal force-pushed the flutter/migrate-to-widget-state/3 branch from 2a42bb6 to 439dfd9 Compare September 10, 2025 08:57
@ValentinVignal ValentinVignal added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 11, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Sep 11, 2025
Merged via the queue into flutter:master with commit d305a32 Sep 11, 2025
78 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 11, 2025
@ValentinVignal ValentinVignal mentioned this pull request Sep 12, 2025
9 tasks
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Sep 12, 2025
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
github-merge-queue bot pushed a commit that referenced this pull request Sep 16, 2025
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
github-merge-queue bot pushed a commit that referenced this pull request Sep 16, 2025
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
dixita0607 pushed a commit to dixita0607/flutter that referenced this pull request Sep 17, 2025
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
dixita0607 pushed a commit to dixita0607/flutter that referenced this pull request Sep 17, 2025
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
mboetger pushed a commit to mboetger/flutter that referenced this pull request Sep 18, 2025
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
mboetger pushed a commit to mboetger/flutter that referenced this pull request Sep 18, 2025
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
mboetger pushed a commit to mboetger/flutter that referenced this pull request Sep 18, 2025
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
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 2025
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
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 2025
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
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 2025
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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants