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