-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Make chip.dart use WidgetStatesController
#161487
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
Make chip.dart use WidgetStatesController
#161487
Conversation
ValentinVignal
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.
I had to make the behavior of chips consistent with InkWell to not hit the issue:
The widget on which setState() or markNeedsBuild() was called was:
RawChip
The widget which was currently being built when the offending call was made was:
InkWell
| statesController.update(WidgetState.disabled, !canTap); | ||
| statesController.update(WidgetState.selected, widget.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.
I need to use canTap instead of widget.isEnabled as InkWell does its logic on the provided callbacks
| if (_canRawChipTap(oldWidget) != _canRawChipTap(widget)) { | ||
| setState(() { | ||
| setMaterialState(MaterialState.disabled, !widget.isEnabled); | ||
| statesController.update(WidgetState.disabled, !canTap); |
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.
Same here
| child: RawChip( | ||
| label: const Text('text'), | ||
| backgroundColor: backgroundColor, | ||
| shape: shape, | ||
| onPressed: () {}, | ||
| ), |
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 also introduces this breaking change. A callback needs to be provided in order for the chip to be truly enabled
|
@bleroux @nate-thegrate @victorsanni , here is the follow up of what we discussed #159422. I put comments where there are some potential issues that could make this PR not mergeable. Tell me what you think about it |
|
Your are right, that it is probably to much of a breaking change. If I understand well, the problem is that Another way would to not share the |
|
As far as
I agree with the points @bleroux made. I'm leaning toward not sharing the |
174a7a3 to
7208482
Compare
|
Thank you for the feedbacks @bleroux and @nate-thegrate . I changed the code to not share the states controller with Also, I believe this PR can be exempted from tests? |
2de0a76 to
85704ba
Compare
nate-thegrate
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, thanks for following up here!
Yeah, I think you're right, since the goal here is to factor out |
558d1a7 to
b92cb74
Compare
|
Any feedback on this @Renzo-Olivares @QuncCccccc ? |
|
Sorry for the late response! I will take a look at this PR as soon as possible! |
1f59d27 to
f385523
Compare
f385523 to
d6b1ffd
Compare
QuncCccccc
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.
Thanks for your patience. Could you help fix the failed tests?
Just a question, do we want to use WidgetStatesController to replace MaterialStateMixin? I'm actually not super familiar with the context, maybe @MitchellGoodwin have any thoughts?
Yes, we prefer WidgetStatesController now. MaterialStateMixin has been semi-deprecated for a while. |
Fixes flutter#128289 Follow up of flutter#128507 and flutter#159422 - Makes `RawChip` use `WidgetStatesController` instead of `MaterialStateMixin` - Remove references of `MaterialState` to replace them with `WidgetState` ## 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]. - [x] 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]. <!-- 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 --------- Co-authored-by: Qun Cheng <[email protected]>
Fixes flutter#128289 Follow up of flutter#128507 and flutter#159422 - Makes `RawChip` use `WidgetStatesController` instead of `MaterialStateMixin` - Remove references of `MaterialState` to replace them with `WidgetState` ## 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]. - [x] 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]. <!-- 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 --------- Co-authored-by: Qun Cheng <[email protected]>
Fixes #128289
Follow up of #128507 and #159422
RawChipuseWidgetStatesControllerinstead ofMaterialStateMixinMaterialStateto replace them withWidgetStatePre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.