Repository navigation
Migrated Checkbox to Material 3 Colors - #110537
Conversation
HansMuller
left a comment
There was a problem hiding this comment.
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.
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.
two-space indent here and below
| 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.
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.
Fixed. Thanks for catching this!
guidezpl
left a comment
There was a problem hiding this comment.
A couple of TODOs
CheckboxThemeData.sideneeds to supportMaterialStateProperty<Side>instead ofSide- Error states
Are you planning on addressing these in this PR or a future one?
guidezpl
left a comment
There was a problem hiding this comment.
One more thing, the useMaterial3 documentation should be updated
I will create a separate PR for the TODOs:) Thanks! |
…rialStateProperty method
| return _colors.onSurface.withOpacity(0.38); | ||
| } | ||
| if (states.contains(MaterialState.selected)) { | ||
| if (states.contains(MaterialState.pressed)) { |
There was a problem hiding this comment.
TODO (future PR): update the code generator to collapse code like this.
guidezpl
left a comment
There was a problem hiding this comment.
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
Checkboxwith the new Material 3 defaults, turn on theuseMaterial3flag in theThemeData:#104446
Pre-launch Checklist
///).