gallery icon indicating copy to clipboard operation
gallery copied to clipboard

Rebuild Triggers a "skip" in the Discrete Slider

Open caseycrogers opened this issue 3 years ago • 3 comments

https://github.com/flutter/gallery/blob/4e28f7ab09ee970ba19fbd527a028452a1c259a7/lib/demos/material/sliders_demo.dart#L61 https://github.com/flutter/gallery/blob/4e28f7ab09ee970ba19fbd527a028452a1c259a7/lib/demos/material/sliders_demo.dart#L136

Because the discrete slider is rounded to 40 but it's initial value is 20, the slider has a weird skip on rebuild. The discrete slider's initial value should be set to 40 or the rounding interval should be set to 20.

Or maybe Slider in flutter/flutter should be updated to only apply discretization on value change, NOT on arbitrary interaction or rebuild?

caseycrogers avatar Jan 29 '22 02:01 caseycrogers

Hi, should I change the initial value of _discreteValue to 40, i.e _discreteValue = RestorableDouble(40) ? thank you

AdiAr11 avatar May 26 '22 11:05 AdiAr11

Actually, it's possible that this is no longer needed, this PR was merged yesterday https://github.com/flutter/flutter/pull/103966

guidezpl avatar May 26 '22 11:05 guidezpl

@guidezpl okay, thank you !

AdiAr11 avatar May 26 '22 11:05 AdiAr11