diff --git a/packages/flutter/lib/src/material/slider_theme.dart b/packages/flutter/lib/src/material/slider_theme.dart index 396cc8e7f3e..0f5adca59ad 100644 --- a/packages/flutter/lib/src/material/slider_theme.dart +++ b/packages/flutter/lib/src/material/slider_theme.dart @@ -1667,7 +1667,7 @@ class RoundedRectSliderTrackShape extends SliderTrackShape with BaseSliderTrackS isDiscrete: isDiscrete, ); final Radius trackRadius = Radius.circular(trackRect.height / 2); - final Radius activeTrackRadius = Radius.circular(trackRect.height / 2 + 1); + final Radius activeTrackRadius = Radius.circular((trackRect.height + additionalActiveTrackHeight) / 2); context.canvas.drawRRect( RRect.fromLTRBAndCorners( diff --git a/packages/flutter/test/material/slider_theme_test.dart b/packages/flutter/test/material/slider_theme_test.dart index 83be5a0d378..7c61bc1e27b 100644 --- a/packages/flutter/test/material/slider_theme_test.dart +++ b/packages/flutter/test/material/slider_theme_test.dart @@ -1218,6 +1218,54 @@ void main() { await gesture.up(); }); + + testWidgets('activeTrackRadius is taken into account when painting the border of the active track', (WidgetTester tester) async { + await tester.pumpWidget(_buildApp( + ThemeData().sliderTheme.copyWith( + trackShape: const RoundedRectSliderTrackShapeWithCustomAdditionalActiveTrackHeight( + additionalActiveTrackHeight: 10.0 + ) + ) + )); + await tester.pumpAndSettle(); + final Offset center = tester.getCenter(find.byType(Slider)); + await tester.startGesture(center); + expect( + find.byType(Slider), + paints + ..rrect(rrect: RRect.fromLTRBAndCorners( + 24.0, 293.0, 24.0, 307.0, + topLeft: const Radius.circular(7.0), + bottomLeft: const Radius.circular(7.0), + )) + ..rrect(rrect: RRect.fromLTRBAndCorners( + 24.0, 298.0, 776.0, 302.0, + topRight: const Radius.circular(2.0), + bottomRight: const Radius.circular(2.0), + )), + ); + }); + +} + +class RoundedRectSliderTrackShapeWithCustomAdditionalActiveTrackHeight extends RoundedRectSliderTrackShape { + const RoundedRectSliderTrackShapeWithCustomAdditionalActiveTrackHeight({required this.additionalActiveTrackHeight}); + final double additionalActiveTrackHeight; + @override + void paint( + PaintingContext context, + Offset offset, { + required RenderBox parentBox, + required SliderThemeData sliderTheme, + required Animation enableAnimation, + required TextDirection textDirection, + required Offset thumbCenter, + bool isDiscrete = false, + bool isEnabled = false, + double additionalActiveTrackHeight = 2.0, + }) { + super.paint(context, offset, parentBox: parentBox, sliderTheme: sliderTheme, enableAnimation: enableAnimation, textDirection: textDirection, thumbCenter: thumbCenter, additionalActiveTrackHeight: this.additionalActiveTrackHeight); + } } Widget _buildApp(