Fix discrete Slider and RangeSlider to enforce thumb height padding when the track shape is non-rounded#164703
Fix discrete Slider and RangeSlider to enforce thumb height padding when the track shape is non-rounded#164703auto-submit[bot] merged 2 commits intoflutter:masterfrom TahaTesser:fix_sliders_discrete_padding
Slider and RangeSlider to enforce thumb height padding when the track shape is non-rounded#164703Conversation
QuncCccccc
left a comment
There was a problem hiding this comment.
This LGTM. Thanks for the fix. Just a little confused about the numbers in the test.
| material, | ||
| paints | ||
| // Start thumb. | ||
| ..circle(x: sliderPadding, y: 300.0, color: theme.colorScheme.primary) |
There was a problem hiding this comment.
Just a question, how do we get this 24? It looks like sliderPadding isn't used anywhere.
There was a problem hiding this comment.
This comes from the track padding applied by base track shape in RangeSlider widget.
Here trackLeft and trackRight are 24 pixels.
flutter/packages/flutter/lib/src/material/slider_theme.dart
Lines 2213 to 2216 in 234b50a
I made such track padding customizable in the Slider widget last year (#156143) but it's not yet implemented in RangeSlider but the I used the same wording here "slider padding" since it's effectively the same thing.
I just filed an issue #165046 and assigned. I will complete the Slider padding work for RangeSlider. Thanks for the reminder.
There was a problem hiding this comment.
Ah I see! Could you add a comment above the number? Thanks a lot for the explanation!
|
The failed Google testing seems related to M2 style. |
|
@QuncCccccc Looks like checks are green. Could you please confirm this fixes the issue you described? |
|
Seems the inactive track part has been fixed🎉, but for the active track, I can still see some failures:) Will talk with @TahaTesser offline. |
Thanks! I'm pretty stumped since the current code in the PR is just restoring the track padding to the way it was before the original slider padding fix. |
…ng when the track shape is non-rounded
QuncCccccc
left a comment
There was a problem hiding this comment.
LGTM! Thanks for your patience. The Scuba diffs look very small, so I think we should just accept them.
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ng when the track shape is non-rounded (flutter#164703) Fixes [Discrete `Slider` and `RangeSlider` applies thumb padding when using custom Slider shapes](flutter#161805) ### Code Sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() => runApp(const RangeSliderExampleApp()); class RangeSliderExampleApp extends StatelessWidget { const RangeSliderExampleApp({super.key}); @OverRide Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( sliderTheme: const SliderThemeData( trackHeight: 32, trackShape: RectangularSliderTrackShape(), rangeTrackShape: RectangularRangeSliderTrackShape(), thumbColor: Colors.amber, ), ), home: Scaffold( body: Column( spacing: 20.0, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Slider( value: 100, max: 100, divisions: 100, onChanged: (double value) {}, ), RangeSlider( values: const RangeValues(0, 100), max: 100, divisions: 100, onChanged: (RangeValues values) {}, ), ], ), ), ); } } ``` </details> ### Before <img width="929" alt="Screenshot 2025-03-06 at 13 33 17" src="proxy.php?url=https://github.com/user-attachments/assets/a089674f-4931-4808-9663-1cd540bf7b11" /> ### After <img width="929" alt="Screenshot 2025-03-06 at 13 33 28" src="proxy.php?url=https://github.com/user-attachments/assets/77fe5708-f2e4-4734-92c2-46e4d8338d0e" /> ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
…ht padding when the track shape is non-rounded (flutter/flutter#164703)
Fixes Discrete
SliderandRangeSliderapplies thumb padding when using custom Slider shapesCode Sample
expand to view the code sample
Before
After
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.