File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class MainWidget extends StatefulWidget {
27
27
28
28
class MainWidgetState extends State <MainWidget > {
29
29
double currentSliderValue = 20 ;
30
+ static const String accessibilityLabel = 'Accessibility Test Slider' ;
30
31
31
32
@override
32
33
Widget build (BuildContext context) {
@@ -36,16 +37,19 @@ class MainWidgetState extends State<MainWidget> {
36
37
title: const Text ('Slider' ),
37
38
),
38
39
body: Center (
39
- child: Slider (
40
- value: currentSliderValue,
41
- max: 100 ,
42
- divisions: 5 ,
43
- label: currentSliderValue.round ().toString (),
44
- onChanged: (double value) {
45
- setState (() {
46
- currentSliderValue = value;
47
- });
48
- },
40
+ child: Semantics (
41
+ label: accessibilityLabel,
42
+ child: Slider (
43
+ value: currentSliderValue,
44
+ max: 100 ,
45
+ divisions: 5 ,
46
+ label: currentSliderValue.round ().toString (),
47
+ onChanged: (double value) {
48
+ setState (() {
49
+ currentSliderValue = value;
50
+ });
51
+ },
52
+ ),
49
53
),
50
54
),
51
55
);
Original file line number Diff line number Diff line change @@ -19,4 +19,9 @@ void main() {
19
19
final MainWidgetState state = tester.state <MainWidgetState >(find.byType (MainWidget ));
20
20
expect (state.currentSliderValue, 60 );
21
21
});
22
+ testWidgets ('slider semantics wrapper exists' , (WidgetTester tester) async {
23
+ await pumpsUseCase (tester, SliderUseCase ());
24
+ final Finder semanticsWidget = find.bySemanticsLabel ('Accessibility Test Slider' );
25
+ expect (semanticsWidget, findsOneWidget);
26
+ });
22
27
}
You can’t perform that action at this time.
0 commit comments