Skip to content

Commit c232620

Browse files
authored
[VPAT][A11y][a11y-app] Add a text label to slider. (flutter#177130)
Fix flutter#173008 Added a visible text label and remove the redundant semantics label. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 38c3741 commit c232620

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

dev/a11y_assessments/lib/use_cases/slider.dart

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class MainWidget extends StatefulWidget {
2828

2929
class MainWidgetState extends State<MainWidget> {
3030
double currentSliderValue = 20;
31-
static const String accessibilityLabel = 'Accessibility Test Slider';
3231

3332
String pageTitle = getUseCaseName(SliderUseCase());
3433

@@ -40,19 +39,22 @@ class MainWidgetState extends State<MainWidget> {
4039
title: Semantics(headingLevel: 1, child: Text('$pageTitle demo')),
4140
),
4241
body: Center(
43-
child: Semantics(
44-
label: accessibilityLabel,
45-
child: Slider(
46-
value: currentSliderValue,
47-
max: 100,
48-
divisions: 5,
49-
label: currentSliderValue.round().toString(),
50-
onChanged: (double value) {
51-
setState(() {
52-
currentSliderValue = value;
53-
});
54-
},
55-
),
42+
child: Column(
43+
mainAxisAlignment: MainAxisAlignment.center,
44+
children: <Widget>[
45+
const Text('My Slider'),
46+
Slider(
47+
value: currentSliderValue,
48+
max: 100,
49+
divisions: 5,
50+
label: currentSliderValue.round().toString(),
51+
onChanged: (double value) {
52+
setState(() {
53+
currentSliderValue = value;
54+
});
55+
},
56+
),
57+
],
5658
),
5759
),
5860
);

dev/a11y_assessments/test/slider_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ 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 {
22+
23+
testWidgets('slider text label exists', (WidgetTester tester) async {
2324
await pumpsUseCase(tester, SliderUseCase());
24-
final Finder semanticsWidget = find.bySemanticsLabel('Accessibility Test Slider');
25-
expect(semanticsWidget, findsOneWidget);
25+
final Finder labelWidget = find.text('My Slider');
26+
expect(labelWidget, findsOneWidget);
2627
});
2728

2829
testWidgets('slider demo page has one h1 tag', (WidgetTester tester) async {

0 commit comments

Comments
 (0)