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 {
2727
2828class MainWidgetState extends State <MainWidget > {
2929 double currentSliderValue = 20 ;
30+ static const String accessibilityLabel = 'Accessibility Test Slider' ;
3031
3132 @override
3233 Widget build (BuildContext context) {
@@ -36,16 +37,19 @@ class MainWidgetState extends State<MainWidget> {
3637 title: const Text ('Slider' ),
3738 ),
3839 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+ ),
4953 ),
5054 ),
5155 );
Original file line number Diff line number Diff line change @@ -19,4 +19,9 @@ void main() {
1919 final MainWidgetState state = tester.state <MainWidgetState >(find.byType (MainWidget ));
2020 expect (state.currentSliderValue, 60 );
2121 });
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+ });
2227}
You can’t perform that action at this time.
0 commit comments