-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RadioListItem use-case to a11y_assessments (#140984)
Adds a use-case screen for `RadioListTile`, similar to the `CheckBoxListTile`. This screen can help test scenarios such as the one reported in #126805.
- Loading branch information
Showing
6 changed files
with
122 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
import 'use_cases.dart'; | ||
|
||
class RadioListTileUseCase extends UseCase { | ||
|
||
@override | ||
String get name => 'RadioListTile'; | ||
|
||
@override | ||
String get route => '/radio-list-tile'; | ||
|
||
@override | ||
Widget build(BuildContext context) => _MainWidget(); | ||
} | ||
|
||
class _MainWidget extends StatefulWidget { | ||
@override | ||
State<_MainWidget> createState() => _MainWidgetState(); | ||
} | ||
|
||
enum SingingCharacter { lafayette, jefferson } | ||
|
||
class _MainWidgetState extends State<_MainWidget> { | ||
SingingCharacter _value = SingingCharacter.lafayette; | ||
|
||
void _onChanged(SingingCharacter? value) { | ||
setState(() { | ||
_value = value!; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar(title: const Text('Radio button')), | ||
body: ListView( | ||
children: <Widget>[ | ||
RadioListTile<SingingCharacter>( | ||
title: const Text('Lafayette'), | ||
value: SingingCharacter.lafayette, | ||
groupValue: _value, | ||
onChanged: _onChanged, | ||
), | ||
RadioListTile<SingingCharacter>( | ||
title: const Text('Jefferson'), | ||
value: SingingCharacter.jefferson, | ||
groupValue: _value, | ||
onChanged: _onChanged, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:a11y_assessments/use_cases/check_box_list_tile.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'test_utils.dart'; | ||
|
||
void main() { | ||
testWidgets('check box list tile use-case renders check boxes', (WidgetTester tester) async { | ||
await pumpsUseCase(tester, CheckBoxListTile()); | ||
expect(find.text('a check box list title'), findsOneWidget); | ||
expect(find.text('a disabled check box list title'), findsOneWidget); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2014 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:a11y_assessments/use_cases/radio_list_tile.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'test_utils.dart'; | ||
|
||
void main() { | ||
testWidgets('radio list tile use-case renders radio buttons', (WidgetTester tester) async { | ||
await pumpsUseCase(tester, RadioListTileUseCase()); | ||
expect(find.text('Lafayette'), findsOneWidget); | ||
expect(find.text('Jefferson'), findsOneWidget); | ||
}); | ||
} |