-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Refactor: Deprecate inactiveColor from cupertino checkbox #152981
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
Refactor: Deprecate inactiveColor from cupertino checkbox #152981
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
|
@victorsanni does this need data driven fixes ? |
4a7de94 to
cbb4f91
Compare
|
@MitchellGoodwin I think this change should wait on the outcome of the WidgetStateProperty discussion? Come to think of it, I wonder why inactiveColor can't just refer to the fill color of the unselected checkbox. It does seem like a simpler API. |
I don't think so, since inactiveColor isn't currently used anyways. |
I think it'd be fine to move forward on this. As a property, toggle colors react to interactive state out of the box more than most widgets, so I think pushing more strongly towards WidgetState is fine.
It probably should have been used as a default for the inactive color, if fillColor was empty. At least until it was deprecated. At a minimum we should update the docs to call out that it both does nothing and that the
If you mean use inactiveColor as a
@rkishan516 As mentioned |
| /// | ||
| /// By default, [CupertinoColors.inactiveGray] is used. | ||
| @Deprecated( | ||
| 'Use fillColor instead. ' |
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.
Looks like this is indented too much
Should this PR also remove every reference to inactiveColor in the documentation? |
407a58b to
8defb06
Compare
|
@victorsanni I have updated the doc. Also removed instances of |
Following up from triage, this will need data driven fixes. The suggestion was to apply fixes conditionally, so if the user already uses fillColor, do nothing. Otherwise, set fillColor to resolve to the user's inactiveColor in the unselected state. |
It should set fillColor to a copy of but use inactiveColor for the unselected state. |
| /// If [fillColor] resolves to null for the requested state, then the fill color | ||
| /// falls back to [activeColor] if the state includes [WidgetState.selected], | ||
| /// or [inactiveColor] otherwise. | ||
| /// or [CupertinoColors.white] with 50% opacity otherwise. |
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 think the 50% opacity comes in when the checkbox is disabled and unselected? Otherwise its completely opaque?
| final WidgetStateProperty<Color?>? fillColor; | ||
|
|
||
| /// The color used if the checkbox is inactive. | ||
| /// Note: [inactiveColor] is no longer being used. |
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.
We try not to use "Note" in our documentation. https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#avoid-empty-prose
I think the original first sentence was fine. It's a quick preview, and they'll see it's deprecated. It's probably best to explain in the paragraph below that it currently does nothing and to point people towards using fillColor to control the color when unselected.
4ff7cf0 to
041bfe7
Compare
041bfe7 to
f9f0e88
Compare
|
@victorsanni and @MitchellGoodwin I have made suggested changes. |
MitchellGoodwin
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.
Thank you for the updates! I left some comments on documentation and the default the data fix should use.
| name: 'fillColor' | ||
| style: optional_named | ||
| argumentValue: | ||
| expression: 'WidgetStatePropertyAll({% inactiveColor %})' |
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.
What we need to be the default is:
WidgetStateProperty.resolveWith<Color>((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return CupertinoColors.white.withOpacity(0.5);
}
if (states.contains(WidgetState.selected)) {
return widget.activeColor ?? CupertinoDynamicColor.resolve(_kDefaultFillColor, context);
}
return {% inactiveColor %};
})
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 have done the change, but since kDefaultFillColor is private, for now I have put the value of _ kDefaultFillColor as it is in here. But I don't think that's what we want. What do you think ?
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.
Apologies, I should have mentioned that. I think it's fine. The risk would be if _kDefaultFillColor changes and somebody had waited until that point to use dart fix with an inactiveColor set but not activeColor and fillColor. I think all of those being true is pretty low, and even if they were at that point it would be an easy fix for them.
| /// state, [fillColor] will be used instead of [inactiveColor]. | ||
| /// | ||
| /// By default, [CupertinoColors.inactiveGray] is used. | ||
| /// state, [fillColor] will be used instead of [CupertinoColors.white]. |
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.
Maybe something like:
Currently [inactiveColor] is not used, and instead [fillColor] controls the color of the background of the checkbox at all states, including when unselected.
and the documentation for fillColor can be left to explain the default.
| @Deprecated( | ||
| 'Use fillColor instead. ' | ||
| 'This feature was deprecated after v3.24.0-0.2.pre.' | ||
| ) |
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.
| @Deprecated( | |
| 'Use fillColor instead. ' | |
| 'This feature was deprecated after v3.24.0-0.2.pre.' | |
| ) | |
| @Deprecated( | |
| 'Use fillColor instead. ' | |
| `fillColor now manages the background color in all states. ' | |
| 'This feature was deprecated after v3.24.0-0.2.pre.' | |
| ) |
Prefer adding another line giving the reasoning.
fcc3619 to
bed7109
Compare
| /// If [fillColor] resolves to null for the requested state, then the fill color | ||
| /// falls back to [activeColor] if the state includes [WidgetState.selected], | ||
| /// or [inactiveColor] otherwise. | ||
| /// or [CupertinoColors.white] with 50% if the state includes [WidgetState.disabled], |
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.
| /// or [CupertinoColors.white] with 50% if the state includes [WidgetState.disabled], | |
| /// [CupertinoColors.white] at 50% opacity if the checkbox is disabled, |
| /// state, [fillColor] will be used instead of [inactiveColor]. | ||
| /// | ||
| /// By default, [CupertinoColors.inactiveGray] is used. | ||
| /// Currently [inactiveColor] is not used, and instead [fillColor] controls the |
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.
| /// Currently [inactiveColor] is not used, and instead [fillColor] controls the | |
| /// Currently [inactiveColor] is not used. Instead, [fillColor] controls the |
bed7109 to
8a988c1
Compare
|
@victorsanni & @MitchellGoodwin I have pushed the mentioned changes. |
|
/b/s/w/ir/x/w/flutter/packages/flutter/lib/src/cupertino/checkbox.dart:198: trailing U+0020 space character |
3620cfa to
2cf0c8c
Compare
Have pushed the fix. |
| /// state, [fillColor] will be used instead of [inactiveColor]. | ||
| /// | ||
| /// By default, [CupertinoColors.inactiveGray] is used. | ||
| /// Currently [inactiveColor] is not used. instead, [fillColor] controls the |
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.
| /// Currently [inactiveColor] is not used. instead, [fillColor] controls the | |
| /// Currently [inactiveColor] is not used. Instead, [fillColor] controls the |
| /// falls back to [activeColor] if the state includes [WidgetState.selected], | ||
| /// or [inactiveColor] otherwise. | ||
| /// [CupertinoColors.white] at 50% opacity if checkbox is disabled, | ||
| /// or [CupertinoColors.white] otherwise. |
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.
| /// or [CupertinoColors.white] otherwise. | |
| /// and [CupertinoColors.white] otherwise. |
2cf0c8c to
d3bcb7e
Compare
|
@victorsanni Pushed Suggested changes as per last conversation. |
MitchellGoodwin
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!
victorsanni
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!
Manual roll requested by [email protected] flutter/flutter@814e49b...2afc452 2024-08-13 [email protected] Roll Flutter Engine from adb1fa9fdbcf to 9054eb43aa26 (2 revisions) (flutter/flutter#153338) 2024-08-13 [email protected] Roll Flutter Engine from af68e772d298 to adb1fa9fdbcf (2 revisions) (flutter/flutter#153336) 2024-08-13 [email protected] Roll Flutter Engine from 07ecd90b7755 to af68e772d298 (3 revisions) (flutter/flutter#153332) 2024-08-13 [email protected] Add fake dependency on flutter_gpu for the docs (flutter/flutter#153325) 2024-08-13 [email protected] Roll Flutter Engine from 5d8ee52e985b to 07ecd90b7755 (7 revisions) (flutter/flutter#153326) 2024-08-12 [email protected] Make CupertinoButton interactive by keyboard shortcuts (flutter/flutter#153126) 2024-08-12 [email protected] Added FlutterEngineGroups to engine architecture doc (flutter/flutter#153100) 2024-08-12 [email protected] Roll Flutter Engine from bcf2dcc09a13 to 5d8ee52e985b (4 revisions) (flutter/flutter#153313) 2024-08-12 [email protected] Disable DevTools when running the hot restart integration test in flutter_tools (flutter/flutter#153247) 2024-08-12 [email protected] Implemented CupertinoButton new styles/sizes (fixes #92525) (flutter/flutter#152845) 2024-08-12 [email protected] Roll pub packages (flutter/flutter#153297) 2024-08-12 [email protected] Refactor: Deprecate inactiveColor from cupertino checkbox (flutter/flutter#152981) 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 [email protected],[email protected],[email protected] 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
…2981) Refactor: Deprecate `inactiveColor` from cupertino checkbox Fixes flutter#151252
…2981) Refactor: Deprecate `inactiveColor` from cupertino checkbox Fixes flutter#151252
Refactor: Deprecate
inactiveColorfrom cupertino checkboxFixes #151252
Pre-launch Checklist
///).