-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Slider: add themeable mouse cursor v2 #96623
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
Slider: add themeable mouse cursor v2 #96623
Conversation
darrenaustin
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. Nice.
| assert(widget.onChangeStart != null); | ||
| widget.onChangeStart!(_lerp(value)); |
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.
Do we know the history of this assert? Is it here just to protect the reference in the call below? If so, yeah it would be good to remove it as you have. But was it actually a requirement of the widget to not have this null (which seems odd)? If so it should be moved to the widget constructor, no? Same for the similar assert in _handleDragEnd.
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 was just to defend against an error being introduced in the original code on lines 751,752. No longer needed.
| final Set<MaterialState> states = <MaterialState>{ | ||
| if (!_enabled) MaterialState.disabled, | ||
| if (_hovering) MaterialState.hovered, | ||
| if (_focused) MaterialState.focused, | ||
| if (_dragging) MaterialState.dragged, | ||
| }; |
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.
Nice set up here. I like this pattern.
| onChangeStart: widget.onChangeStart != null ? _handleDragStart : null, | ||
| onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : 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.
Wow, that seemed like a convoluted way to hook up the callback. Nice cleanup.
Allow themes to override Slider's mouse cursor.
Partial fix to #88371
This PR is based on #88425 (author: @jpnurmi). It's been extended a little per the review feedback for the PR. PR #88371 wasn't reviewed for months by yours truly, so I'm completing the project here.