Add more widgets to a11y assessment app (#152662)
## 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]. <!-- 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
This commit is contained in:
parent
ac039025e7
commit
8a4812a6da
54
dev/a11y_assessments/lib/use_cases/action_chip.dart
Normal file
54
dev/a11y_assessments/lib/use_cases/action_chip.dart
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
// 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 ActionChipUseCase extends UseCase {
|
||||||
|
@override
|
||||||
|
String get name => 'ActionChip';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get route => '/action-chip';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => const MainWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainWidget extends StatefulWidget {
|
||||||
|
const MainWidget({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MainWidget> createState() => MainWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainWidgetState extends State<MainWidget> {
|
||||||
|
bool favorite = false;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||||
|
title: const Text('ActionChip'),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
ActionChip(
|
||||||
|
avatar: const Icon(Icons.favorite),
|
||||||
|
label: const Text('Action'),
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
|
const ActionChip(
|
||||||
|
avatar: Icon(Icons.favorite),
|
||||||
|
label: Text('Action'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
51
dev/a11y_assessments/lib/use_cases/card.dart
Normal file
51
dev/a11y_assessments/lib/use_cases/card.dart
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// 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 CardUseCase extends UseCase {
|
||||||
|
@override
|
||||||
|
String get name => 'Card';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get route => '/card';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => const MainWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainWidget extends StatefulWidget {
|
||||||
|
const MainWidget({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MainWidget> createState() => MainWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainWidgetState extends State<MainWidget> {
|
||||||
|
bool favorite = false;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||||
|
title: const Text('Card'),
|
||||||
|
),
|
||||||
|
body: const Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Card(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(16),
|
||||||
|
child: Text('Card'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
74
dev/a11y_assessments/lib/use_cases/expansion_tile.dart
Normal file
74
dev/a11y_assessments/lib/use_cases/expansion_tile.dart
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
// 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 ExpansionTileUseCase extends UseCase {
|
||||||
|
@override
|
||||||
|
String get name => 'ExpansionTile';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get route => '/expansion-tile';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => const ExpansionTileExample();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ExpansionTileExample extends StatefulWidget {
|
||||||
|
const ExpansionTileExample({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ExpansionTileExample> createState() => _ExpansionTileExampleState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ExpansionTileExampleState extends State<ExpansionTileExample> {
|
||||||
|
bool _customTileExpanded = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||||
|
title: const Text('ExpansionTile'),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
const ExpansionTile(
|
||||||
|
title: Text('ExpansionTile 1'),
|
||||||
|
subtitle: Text('Trailing expansion arrow icon'),
|
||||||
|
children: <Widget>[
|
||||||
|
ListTile(title: Text('This is tile number 1')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
ExpansionTile(
|
||||||
|
title: const Text('ExpansionTile 2'),
|
||||||
|
subtitle: const Text('Custom expansion arrow icon'),
|
||||||
|
trailing: Icon(
|
||||||
|
_customTileExpanded ? Icons.arrow_drop_down_circle : Icons.arrow_drop_down,
|
||||||
|
),
|
||||||
|
children: const <Widget>[
|
||||||
|
ListTile(title: Text('This is tile number 2')),
|
||||||
|
],
|
||||||
|
onExpansionChanged: (bool expanded) {
|
||||||
|
setState(() {
|
||||||
|
_customTileExpanded = expanded;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const ExpansionTile(
|
||||||
|
title: Text('ExpansionTile 3'),
|
||||||
|
subtitle: Text('Leading expansion arrow icon'),
|
||||||
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
|
children: <Widget>[
|
||||||
|
ListTile(title: Text('This is tile number 3')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
67
dev/a11y_assessments/lib/use_cases/snack_bar.dart
Normal file
67
dev/a11y_assessments/lib/use_cases/snack_bar.dart
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// 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 SnackBarUseCase extends UseCase {
|
||||||
|
@override
|
||||||
|
String get name => 'SnackBar';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get route => '/snack-bar';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => const MainWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainWidget extends StatefulWidget {
|
||||||
|
const MainWidget({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MainWidget> createState() => MainWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class MainWidgetState extends State<MainWidget> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||||
|
title: const Text('SnackBar'),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
ElevatedButton(
|
||||||
|
child: const Text('Show Snackbar'),
|
||||||
|
onPressed: () {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Awesome Snackbar!'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
child: const Text('Show Snackbar with action '),
|
||||||
|
onPressed: () {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: const Text('Awesome Snackbar!'),
|
||||||
|
action: SnackBarAction(
|
||||||
|
label: 'Action',
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
66
dev/a11y_assessments/lib/use_cases/switch_list_tile.dart
Normal file
66
dev/a11y_assessments/lib/use_cases/switch_list_tile.dart
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
// 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 SwitchListTileUseCase extends UseCase {
|
||||||
|
@override
|
||||||
|
String get name => 'SwitchListTile';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get route => '/switch-list-tile';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => const SwitchListTileExample();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SwitchListTileExample extends StatefulWidget {
|
||||||
|
const SwitchListTileExample({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SwitchListTileExample> createState() => _SwitchListTileExampleState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SwitchListTileExampleState extends State<SwitchListTileExample> {
|
||||||
|
bool _lights1 = false;
|
||||||
|
bool _lights2 = false;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||||
|
title: const Text('SwitchListTile'),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SwitchListTile(
|
||||||
|
title: const Text('Lights'),
|
||||||
|
value: _lights1,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
setState(() {
|
||||||
|
_lights1 = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
secondary: const Icon(Icons.lightbulb_outline),
|
||||||
|
),
|
||||||
|
SwitchListTile(
|
||||||
|
title: const Text('Lights'),
|
||||||
|
subtitle: const Text('Subtitle'),
|
||||||
|
value: _lights2,
|
||||||
|
onChanged: (bool value) {
|
||||||
|
setState(() {
|
||||||
|
_lights2 = value;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
secondary: const Icon(Icons.lightbulb_outline),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -4,15 +4,20 @@
|
|||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
import 'action_chip.dart';
|
||||||
import 'auto_complete.dart';
|
import 'auto_complete.dart';
|
||||||
import 'badge.dart';
|
import 'badge.dart';
|
||||||
|
import 'card.dart';
|
||||||
import 'check_box_list_tile.dart';
|
import 'check_box_list_tile.dart';
|
||||||
import 'date_picker.dart';
|
import 'date_picker.dart';
|
||||||
import 'dialog.dart';
|
import 'dialog.dart';
|
||||||
|
import 'expansion_tile.dart';
|
||||||
import 'material_banner.dart';
|
import 'material_banner.dart';
|
||||||
import 'navigation_bar.dart';
|
import 'navigation_bar.dart';
|
||||||
import 'radio_list_tile.dart';
|
import 'radio_list_tile.dart';
|
||||||
import 'slider.dart';
|
import 'slider.dart';
|
||||||
|
import 'snack_bar.dart';
|
||||||
|
import 'switch_list_tile.dart';
|
||||||
import 'text_button.dart';
|
import 'text_button.dart';
|
||||||
import 'text_field.dart';
|
import 'text_field.dart';
|
||||||
import 'text_field_password.dart';
|
import 'text_field_password.dart';
|
||||||
@ -36,4 +41,9 @@ final List<UseCase> useCases = <UseCase>[
|
|||||||
NavigationBarUseCase(),
|
NavigationBarUseCase(),
|
||||||
TextButtonUseCase(),
|
TextButtonUseCase(),
|
||||||
RadioListTileUseCase(),
|
RadioListTileUseCase(),
|
||||||
|
ActionChipUseCase(),
|
||||||
|
SnackBarUseCase(),
|
||||||
|
SwitchListTileUseCase(),
|
||||||
|
ExpansionTileUseCase(),
|
||||||
|
CardUseCase(),
|
||||||
];
|
];
|
||||||
|
16
dev/a11y_assessments/test/action_chip_test.dart
Normal file
16
dev/a11y_assessments/test/action_chip_test.dart
Normal file
@ -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/action_chip.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('action chip can run', (WidgetTester tester) async {
|
||||||
|
await pumpsUseCase(tester, ActionChipUseCase());
|
||||||
|
expect(find.byType(ActionChip), findsExactly(2));
|
||||||
|
});
|
||||||
|
}
|
16
dev/a11y_assessments/test/card_test.dart
Normal file
16
dev/a11y_assessments/test/card_test.dart
Normal file
@ -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/card.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('card can run', (WidgetTester tester) async {
|
||||||
|
await pumpsUseCase(tester, CardUseCase());
|
||||||
|
expect(find.byType(Card), findsExactly(1));
|
||||||
|
});
|
||||||
|
}
|
16
dev/a11y_assessments/test/expansion_tile_test.dart
Normal file
16
dev/a11y_assessments/test/expansion_tile_test.dart
Normal file
@ -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/expansion_tile.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('action chip can run', (WidgetTester tester) async {
|
||||||
|
await pumpsUseCase(tester, ExpansionTileUseCase());
|
||||||
|
expect(find.byType(ExpansionTile), findsExactly(3));
|
||||||
|
});
|
||||||
|
}
|
20
dev/a11y_assessments/test/snack_bar_test.dart
Normal file
20
dev/a11y_assessments/test/snack_bar_test.dart
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// 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/snack_bar.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('snack bar can run', (WidgetTester tester) async {
|
||||||
|
await pumpsUseCase(tester, SnackBarUseCase());
|
||||||
|
const String snackBarText = 'Awesome Snackbar!';
|
||||||
|
expect(find.text(snackBarText), findsNothing);
|
||||||
|
await tester.tap(find.text('Show Snackbar'));
|
||||||
|
expect(find.text(snackBarText), findsNothing);
|
||||||
|
await tester.pump();
|
||||||
|
expect(find.text(snackBarText), findsOneWidget);
|
||||||
|
});
|
||||||
|
}
|
16
dev/a11y_assessments/test/switch_list_tile_test.dart
Normal file
16
dev/a11y_assessments/test/switch_list_tile_test.dart
Normal file
@ -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/switch_list_tile.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
testWidgets('action chip can run', (WidgetTester tester) async {
|
||||||
|
await pumpsUseCase(tester, SwitchListTileUseCase());
|
||||||
|
expect(find.byType(SwitchListTile), findsExactly(2));
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user