-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Migrated Checkbox
to Material 3 Colors
#110537
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
Migrated Checkbox
to Material 3 Colors
#110537
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.
It seems possible that the implementation of this widget could be made substantially simpler in a future PR. Perhaps the code that computes "effective" colors by adding a state to the widgets actual state, could be deferred. So that the painter only computed those colors when it needed them. The division of labor between the Toggleable classes and this class seems like more overhead than should be needed.
if (states.contains(MaterialState.pressed)) { | ||
return ${componentColor('md.comp.checkbox.unselected.pressed.state-layer')}; | ||
} | ||
return null; |
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.
CC @darrenaustin
Should this be Colors.transparent?
?? checkboxTheme.fillColor?.resolve(inactiveStates) | ||
?? _defaultFillColor.resolve(inactiveStates); | ||
final Color? activeColor = widget.fillColor?.resolve(activeStates) | ||
?? _widgetFillColor.resolve(activeStates) |
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.
two-space indent here and below
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.
Done.
if (states.contains(MaterialState.hovered)) { | ||
return ${componentColor('md.comp.checkbox.selected.hover.container')}; | ||
} | ||
if (states.contains(MaterialState.pressed)) { |
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.
Should the pressed test come first (here and elsewhere)? When pressed becomes true, hovered will also always be true, and so we'll miss this if statement.
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.
Fixed. Thanks for catching this!
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.
A couple of TODOs
CheckboxThemeData.side
needs to supportMaterialStateProperty<Side>
instead ofSide
- Error states
Are you planning on addressing these in this PR or a future one?
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.
One more thing, the useMaterial3
documentation should be updated
I will create a separate PR for the TODOs:) Thanks! |
…rialStateProperty method
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
return _colors.onSurface.withOpacity(0.38); | ||
} | ||
if (states.contains(MaterialState.selected)) { | ||
if (states.contains(MaterialState.pressed)) { |
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 (future PR): update the code generator to collapse code like this.
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.
Edited the description to not close the issue, pending the remaining work.
Checkbox
to Material 3Checkbox
to Material 3 Colors
Updated checkbox colors so they use the material 3 palette.
In order to use the
Checkbox
with the new Material 3 defaults, turn on theuseMaterial3
flag in theThemeData
:#104446
Pre-launch Checklist
///
).