@@ -2648,6 +2648,35 @@ void main() {
26482648 }
26492649 });
26502650 });
2651+ testWidgets ('indicator shape skips all painting at label is null' ,
2652+ (WidgetTester tester) async {
2653+ debugDisableShadows = false ;
2654+ try {
2655+ await tester.pumpWidget (_buildSilderApp ());
2656+
2657+ final RenderBox valueIndicatorBox =
2658+ tester.renderObject (find.byType (Overlay ));
2659+
2660+ // Calculate a specific position on the Slider
2661+ final Rect sliderRect = tester.getRect (find.byType (Slider ));
2662+ final Offset tapPositionLeft = Offset (
2663+ sliderRect.left + sliderRect.width * 0.25 , sliderRect.center.dy);
2664+ final Offset tapPositionRight = Offset (
2665+ sliderRect.left + sliderRect.width * 0.75 , sliderRect.center.dy);
2666+
2667+ // Tap on the 25% position of the Slider
2668+ await tester.tapAt (tapPositionLeft);
2669+ await tester.pumpAndSettle ();
2670+ expect (valueIndicatorBox, paintsExactlyCountTimes (#drawPath, 1 ));
2671+
2672+ // Tap on the 75% position of the Slider
2673+ await tester.tapAt (tapPositionRight);
2674+ await tester.pumpAndSettle ();
2675+ expect (valueIndicatorBox, paintsExactlyCountTimes (#drawPath, 0 ));
2676+ } finally {
2677+ debugDisableShadows = true ;
2678+ }
2679+ });
26512680}
26522681
26532682class RoundedRectSliderTrackShapeWithCustomAdditionalActiveTrackHeight extends RoundedRectSliderTrackShape {
@@ -2722,3 +2751,25 @@ Widget _buildRangeApp(
27222751 ),
27232752 );
27242753}
2754+ Widget _buildSilderApp () {
2755+ double sliderValue = 10 ;
2756+ return MaterialApp (
2757+ home: StatefulBuilder (
2758+ builder: (BuildContext context, void Function (void Function ()) setState) {
2759+ return Material (
2760+ child: Slider (
2761+ value: sliderValue,
2762+ max: 100 ,
2763+ label: sliderValue > 50 ? null : sliderValue.toString (),
2764+ divisions: 10 ,
2765+ onChanged: (double value) {
2766+ setState (() {
2767+ sliderValue = value;
2768+ });
2769+ },
2770+ ),
2771+ );
2772+ },
2773+ ),
2774+ );
2775+ }
0 commit comments