mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Use additionalActiveTrackHeight when painting the radius of RoundedRectSliderTrackShape's active track (#85697)
This commit is contained in:
parent
257430b634
commit
6136e36ce5
|
@ -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(
|
||||
|
|
|
@ -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<double> 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(
|
||||
|
|
Loading…
Reference in a new issue