@@ -4484,12 +4484,12 @@ void main() {
4484
4484
),
4485
4485
);
4486
4486
4487
- // Slider does not show value indicator initially.
4487
+ // Slider shows value indicator initially on focus .
4488
4488
await tester.pumpAndSettle ();
4489
4489
RenderBox valueIndicatorBox = tester.renderObject (find.byType (Overlay ));
4490
4490
expect (
4491
4491
valueIndicatorBox,
4492
- isNot ( paints..scale ()..path (color: theme.colorScheme.primary) ),
4492
+ paints..scale ()..path (color: theme.colorScheme.primary),
4493
4493
);
4494
4494
4495
4495
// Right arrow (increase)
@@ -4548,4 +4548,54 @@ void main() {
4548
4548
paints..scale ()..path (color: theme.colorScheme.primary),
4549
4549
);
4550
4550
}, variant: TargetPlatformVariant .desktop ());
4551
+
4552
+ testWidgets ('Value indicator label is shown when focused' , (WidgetTester tester) async {
4553
+ double value = 0.5 ;
4554
+ final FocusNode focusNode = FocusNode ();
4555
+ addTearDown (focusNode.dispose);
4556
+
4557
+ Widget buildApp () {
4558
+ return MaterialApp (
4559
+ home: Material (
4560
+ child: Center (
4561
+ child: StatefulBuilder (builder: (BuildContext context, StateSetter setState) {
4562
+ return Slider (
4563
+ value: value,
4564
+ focusNode: focusNode,
4565
+ divisions: 5 ,
4566
+ label: value.toStringAsFixed (1 ),
4567
+ onChanged:
4568
+ (double newValue) {
4569
+ setState (() {
4570
+ value = newValue;
4571
+ });
4572
+ }
4573
+ );
4574
+ }),
4575
+ ),
4576
+ ),
4577
+ );
4578
+ }
4579
+ await tester.pumpWidget (buildApp ());
4580
+
4581
+ // Slider does not show value indicator without focus.
4582
+ await tester.pumpAndSettle ();
4583
+ expect (focusNode.hasFocus, false );
4584
+ RenderBox valueIndicatorBox = tester.renderObject (find.byType (Overlay ));
4585
+ expect (
4586
+ valueIndicatorBox,
4587
+ isNot (paints..path (color: const Color (0xff000000 ))..paragraph ()),
4588
+ );
4589
+
4590
+ focusNode.requestFocus ();
4591
+ await tester.pumpAndSettle ();
4592
+ expect (focusNode.hasFocus, true );
4593
+
4594
+ // Slider shows value indicator when focused.
4595
+ valueIndicatorBox = tester.renderObject (find.byType (Overlay ));
4596
+ expect (
4597
+ valueIndicatorBox,
4598
+ paints..path (color: const Color (0xff000000 ))..paragraph (),
4599
+ );
4600
+ }, variant: TargetPlatformVariant .desktop ());
4551
4601
}
0 commit comments