Skip to content

Commit 0bbac72

Browse files
authored
[Material] Fix slider track shape to rounded (flutter#34178)
The slider track shape for the onPrimaryColors constructor should be rounded, but it was accidentally changed to rectangular in flutter#31681. This change restores the original behavior. This only affects sliders that are themed with SliderThemeData.onPrimaryColors().
1 parent c88f64e commit 0bbac72

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

packages/flutter/lib/src/material/slider_theme.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ class SliderThemeData extends Diagnosticable {
417417
overlayShape: const RoundSliderOverlayShape(),
418418
tickMarkShape: const RoundSliderTickMarkShape(),
419419
thumbShape: const RoundSliderThumbShape(),
420-
trackShape: const RectangularSliderTrackShape(),
420+
trackShape: const RoundedRectSliderTrackShape(),
421421
valueIndicatorShape: const PaddleSliderValueIndicatorShape(),
422422
rangeTickMarkShape: const RoundRangeSliderTickMarkShape(),
423423
rangeThumbShape: const RoundRangeSliderThumbShape(),

packages/flutter/test/material/slider_theme_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,30 @@ void main() {
163163
expect(sliderTheme.valueIndicatorTextStyle.color, equals(customColor4));
164164
});
165165

166+
testWidgets('SliderThemeData generates correct shapes for fromPrimaryColors', (WidgetTester tester) async {
167+
const Color customColor1 = Color(0xcafefeed);
168+
const Color customColor2 = Color(0xdeadbeef);
169+
const Color customColor3 = Color(0xdecaface);
170+
const Color customColor4 = Color(0xfeedcafe);
171+
172+
final SliderThemeData sliderTheme = SliderThemeData.fromPrimaryColors(
173+
primaryColor: customColor1,
174+
primaryColorDark: customColor2,
175+
primaryColorLight: customColor3,
176+
valueIndicatorTextStyle: ThemeData.fallback().accentTextTheme.body2.copyWith(color: customColor4),
177+
);
178+
179+
expect(sliderTheme.overlayShape, const RoundSliderOverlayShape());
180+
expect(sliderTheme.tickMarkShape, const RoundSliderTickMarkShape());
181+
expect(sliderTheme.thumbShape, const RoundSliderThumbShape());
182+
expect(sliderTheme.trackShape, const RoundedRectSliderTrackShape());
183+
expect(sliderTheme.valueIndicatorShape, const PaddleSliderValueIndicatorShape());
184+
expect(sliderTheme.rangeTickMarkShape, const RoundRangeSliderTickMarkShape());
185+
expect(sliderTheme.rangeThumbShape, const RoundRangeSliderThumbShape());
186+
expect(sliderTheme.rangeTrackShape, const RoundedRectRangeSliderTrackShape());
187+
expect(sliderTheme.rangeValueIndicatorShape, const PaddleRangeSliderValueIndicatorShape());
188+
});
189+
166190
testWidgets('SliderThemeData lerps correctly', (WidgetTester tester) async {
167191
final SliderThemeData sliderThemeBlack = SliderThemeData.fromPrimaryColors(
168192
primaryColor: Colors.black,

0 commit comments

Comments
 (0)