Slider and RangeSlider can be painted in a narrower constraint like other Material Wi…#64627
Conversation
…dget such as Switch
…dget such as Switch
HansMuller
left a comment
There was a problem hiding this comment.
This looks OK to me. It would be helpful to include a screenshot in the PR's description, to demo what happens when the width gets small.
Deferring to Anthony and Jose...
| return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight); | ||
| final double trackRight = trackLeft + parentBox.size.width - math.max(thumbWidth, overlayWidth); | ||
| final double trackButtom = trackTop + trackHeight; | ||
| // if the parentBox.size < slider's size, the trackRight will less then trackLeft, we need switch them. |
There was a problem hiding this comment.
If the .. will be less.., so switch them.
HansMuller
left a comment
There was a problem hiding this comment.
Need to fixup the analyzer errors..
Fixed. I update the PR description above. |
| isDiscrete: isDiscrete, | ||
| ); | ||
| final Rect leftTrackSegment = Rect.fromLTRB(trackRect.left, trackRect.top, leftThumbOffset.dx - thumbRadius, trackRect.bottom); | ||
| final Rect leftTrackSegment = Rect.fromLTRB(trackRect.left, trackRect.top, leftThumbOffset.dx, trackRect.bottom); |
There was a problem hiding this comment.
I remove the gap between the inactive track and active track, also see #64534
|
@clocksmith Hi, please review. :) |
HansMuller
left a comment
There was a problem hiding this comment.
The inexplicable extra import of dart:math in slider.dart could be broken out as a separate PR. Should be a quickie.
OK, I will do it right now. |
Done. #65060 |
…ther Material Wi… (flutter#64627)
Description
This PR change
Slidercan not be painted in a narrower constraint like other Material Widgets such asSwitch.If I just remove the assert checks, the fellow demo code paint

Sliderincorrectly below(the active track and inactive track switched mistake), so I modify thegetPreferredRectlogic.After change:

The issue #64629 root cause is that, when minimizing the window the screen size will change to zero and trigger a
flushPaint.This change does make the appearance of the issue disappear, but I am not sure whether the window size change to zero is intended, I think we can track that at a new issue, right?
DEMO
Related Issues
Fixes #64629
Tests
I added the following tests:
See files.
Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.