Auto-format Framework (#160545)

This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -12,10 +12,6 @@ class DynamicTitle extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Title(
title: title,
color: Theme.of(context).colorScheme.primary,
child: child,
);
return Title(title: title, color: Theme.of(context).colorScheme.primary, child: child);
}
}

View File

@@ -21,21 +21,26 @@ class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ThemeData lightTheme = ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xff6750a4),
contrastLevel: MediaQuery.highContrastOf(context) ? 1.0 : 0.0,
));
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xff6750a4),
contrastLevel: MediaQuery.highContrastOf(context) ? 1.0 : 0.0,
),
);
final ThemeData darkTheme = ThemeData(
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.dark,
seedColor: const Color(0xff6750a4),
contrastLevel: MediaQuery.highContrastOf(context) ? 1.0 : 0.0,
));
colorScheme: ColorScheme.fromSeed(
brightness: Brightness.dark,
seedColor: const Color(0xff6750a4),
contrastLevel: MediaQuery.highContrastOf(context) ? 1.0 : 0.0,
),
);
final Map<String, WidgetBuilder> routes =
Map<String, WidgetBuilder>.fromEntries(
useCases.map((UseCase useCase) =>
MapEntry<String, WidgetBuilder>(useCase.route, (BuildContext context) => useCase.buildWithTitle(context))),
final Map<String, WidgetBuilder> routes = Map<String, WidgetBuilder>.fromEntries(
useCases.map(
(UseCase useCase) => MapEntry<String, WidgetBuilder>(
useCase.route,
(BuildContext context) => useCase.buildWithTitle(context),
),
),
);
return MaterialApp(
@@ -65,22 +70,25 @@ class HomePageState extends State<HomePage> {
Widget _buildUseCaseItem(int index, UseCase useCase) {
return Padding(
padding: const EdgeInsets.all(10),
child: Builder(builder: (BuildContext context) {
padding: const EdgeInsets.all(10),
child: Builder(
builder: (BuildContext context) {
return TextButton(
key: Key(useCase.name),
onPressed: () => Navigator.of(context).pushNamed(useCase.route, arguments: useCase.name),
onPressed:
() => Navigator.of(context).pushNamed(useCase.route, arguments: useCase.name),
child: Text(useCase.name),
);
}));
},
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Semantics(headingLevel: 1, child: const Text('Accessibility Assessments')),
title: Semantics(headingLevel: 1, child: const Text('Accessibility Assessments')),
),
body: Center(
child: ListView(

View File

@@ -34,7 +34,7 @@ class MainWidgetState extends State<MainWidget> {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Semantics(headingLevel:1, child: Text('$pageTitle Demo')),
title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo')),
),
body: Center(
child: Column(
@@ -45,10 +45,7 @@ class MainWidgetState extends State<MainWidget> {
label: const Text('Action'),
onPressed: () {},
),
const ActionChip(
avatar: Icon(Icons.favorite),
label: Text('Action'),
),
const ActionChip(avatar: Icon(Icons.favorite), label: Text('Action')),
],
),
),

View File

@@ -36,63 +36,58 @@ class MainWidgetState extends State<MainWidget> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: <PreferredSizeWidget>[
AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Semantics(headingLevel: 1, child: const Text('AppBar')),
),
AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Semantics(headingLevel: 1, child: const Text('AppBar')),
actions: <Widget>[
IconButton(
icon: const Icon(Icons.add_alert),
tooltip: 'Show Snackbar',
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('This is a snackbar')));
},
appBar:
<PreferredSizeWidget>[
AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Semantics(headingLevel: 1, child: const Text('AppBar')),
),
IconButton(
icon: const Icon(Icons.navigate_next),
tooltip: 'Go to the next page',
onPressed: () {
Navigator.push(context, MaterialPageRoute<void>(
builder: (BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor:
Theme.of(context).colorScheme.inversePrimary,
title: Semantics(headingLevel: 1, child: const Text('Next Page')),
),
body: const Center(
child: Text(
'This is the next page',
style: TextStyle(fontSize: 24),
),
AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Semantics(headingLevel: 1, child: const Text('AppBar')),
actions: <Widget>[
IconButton(
icon: const Icon(Icons.add_alert),
tooltip: 'Show Snackbar',
onPressed: () {
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('This is a snackbar')));
},
),
IconButton(
icon: const Icon(Icons.navigate_next),
tooltip: 'Go to the next page',
onPressed: () {
Navigator.push(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Semantics(headingLevel: 1, child: const Text('Next Page')),
),
body: const Center(
child: Text('This is the next page', style: TextStyle(fontSize: 24)),
),
);
},
),
);
},
));
},
),
],
),
],
),
AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Semantics(headingLevel: 1, child: const Text('AppBar')),
actions: <Widget>[
TextButton(
onPressed: () {},
child: const Text('Action 1'),
AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Semantics(headingLevel: 1, child: const Text('AppBar')),
actions: <Widget>[
TextButton(onPressed: () {}, child: const Text('Action 1')),
TextButton(onPressed: () {}, child: const Text('Action 2')),
],
),
TextButton(
onPressed: () {},
child: const Text('Action 2'),
),
],
),
][currentIndex],
][currentIndex],
body: ListView(
children: <Widget>[
RadioListTile<int>(

View File

@@ -25,17 +25,14 @@ class _MainWidget extends StatefulWidget {
}
class _MainWidgetState extends State<_MainWidget> {
static const List<String> _kOptions = <String>[
'apple',
'banana',
'lemon',
];
static const List<String> _kOptions = <String>['apple', 'banana', 'lemon'];
static Widget _fieldViewBuilder(
BuildContext context,
TextEditingController textEditingController,
FocusNode focusNode,
VoidCallback onFieldSubmitted) {
BuildContext context,
TextEditingController textEditingController,
FocusNode focusNode,
VoidCallback onFieldSubmitted,
) {
return TextFormField(
focusNode: focusNode,
controller: textEditingController,
@@ -58,8 +55,7 @@ class _MainWidgetState extends State<_MainWidget> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Type below to autocomplete the following possible results: $_kOptions.'),
Text('Type below to autocomplete the following possible results: $_kOptions.'),
Autocomplete<String>(
optionsBuilder: (TextEditingValue textEditingValue) {
if (textEditingValue.text == '') {

View File

@@ -36,11 +36,7 @@ class MainWidgetState extends State<MainWidget> {
),
body: const Center(
child: Badge(
label: Text(
'5',
semanticsLabel: '5 new messages',
style: TextStyle(color: Colors.white),
),
label: Text('5', semanticsLabel: '5 new messages', style: TextStyle(color: Colors.white)),
backgroundColor: Colors.green,
child: Icon(Icons.mail, semanticLabel: 'Messages'),
),

View File

@@ -40,12 +40,7 @@ class MainWidgetState extends State<MainWidget> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Card(
child: Padding(
padding: EdgeInsets.all(16),
child: Text('Card'),
),
),
Card(child: Padding(padding: EdgeInsets.all(16), child: Text('Card'))),
],
),
),

View File

@@ -30,9 +30,7 @@ class _MainWidgetState extends State<_MainWidget> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo')),
),
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
body: ListView(
children: <Widget>[
CheckboxListTile(

View File

@@ -25,7 +25,6 @@ class _MainWidget extends StatefulWidget {
}
class _MainWidgetState extends State<_MainWidget> {
String pageTitle = getUseCaseName(DatePickerUseCase());
@override
@@ -37,13 +36,14 @@ class _MainWidgetState extends State<_MainWidget> {
),
body: Center(
child: TextButton(
onPressed: () => showDatePicker(
context: context,
initialEntryMode: DatePickerEntryMode.calendarOnly,
initialDate: DateTime.now(),
firstDate: DateTime.now().subtract(const Duration(days: 365)),
lastDate: DateTime.now().add(const Duration(days: 365)),
),
onPressed:
() => showDatePicker(
context: context,
initialEntryMode: DatePickerEntryMode.calendarOnly,
initialDate: DateTime.now(),
firstDate: DateTime.now().subtract(const Duration(days: 365)),
lastDate: DateTime.now().add(const Duration(days: 365)),
),
child: const Text('Show Date Picker'),
),
),

View File

@@ -31,40 +31,42 @@ class _MainWidget extends StatelessWidget {
),
body: Center(
child: TextButton(
onPressed: () => showDialog<String>(
context: context,
builder: (BuildContext context) => Dialog(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('This is a typical dialog.'),
const SizedBox(height: 15),
Row(
children: <Widget>[
TextButton(
key: const Key('OK Button'),
autofocus: true,
onPressed: () {
Navigator.pop(context);
},
child: const Text('OK'),
onPressed:
() => showDialog<String>(
context: context,
builder:
(BuildContext context) => Dialog(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text('This is a typical dialog.'),
const SizedBox(height: 15),
Row(
children: <Widget>[
TextButton(
key: const Key('OK Button'),
autofocus: true,
onPressed: () {
Navigator.pop(context);
},
child: const Text('OK'),
),
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Cancel'),
),
],
),
],
),
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Cancel'),
),
],
),
),
],
),
),
),
),
child: const Text('Show Dialog'),
),
),

View File

@@ -41,16 +41,8 @@ class _DrawerExampleState extends State<DrawerExample> {
padding: EdgeInsets.zero,
children: <Widget>[
const DrawerHeader(
decoration: BoxDecoration(
color: Colors.blue,
),
child: Text(
'Drawer Header',
style: TextStyle(
color: Colors.white,
fontSize: 24,
),
),
decoration: BoxDecoration(color: Colors.blue),
child: Text('Drawer Header', style: TextStyle(color: Colors.white, fontSize: 24)),
),
ListTile(
leading: const Icon(Icons.message),
@@ -82,9 +74,7 @@ class _DrawerExampleState extends State<DrawerExample> {
],
),
),
body: Center(
child: Text('Page: $selectedPage'),
),
body: Center(child: Text('Page: $selectedPage')),
);
}
}

View File

@@ -41,9 +41,7 @@ class _ExpansionTileExampleState extends State<ExpansionTileExample> {
const ExpansionTile(
title: Text('ExpansionTile 1'),
subtitle: Text('Trailing expansion arrow icon'),
children: <Widget>[
ListTile(title: Text('This is tile number 1')),
],
children: <Widget>[ListTile(title: Text('This is tile number 1'))],
),
ExpansionTile(
title: const Text('ExpansionTile 2'),
@@ -51,9 +49,7 @@ class _ExpansionTileExampleState extends State<ExpansionTileExample> {
trailing: Icon(
_customTileExpanded ? Icons.arrow_drop_down_circle : Icons.arrow_drop_down,
),
children: const <Widget>[
ListTile(title: Text('This is tile number 2')),
],
children: const <Widget>[ListTile(title: Text('This is tile number 2'))],
onExpansionChanged: (bool expanded) {
setState(() {
_customTileExpanded = expanded;
@@ -64,9 +60,7 @@ class _ExpansionTileExampleState extends State<ExpansionTileExample> {
title: Text('ExpansionTile 3'),
subtitle: Text('Leading expansion arrow icon'),
controlAffinity: ListTileControlAffinity.leading,
children: <Widget>[
ListTile(title: Text('This is tile number 3')),
],
children: <Widget>[ListTile(title: Text('This is tile number 3'))],
),
],
),

View File

@@ -25,7 +25,6 @@ class MainWidget extends StatefulWidget {
}
class MainWidgetState extends State<MainWidget> {
final FocusNode dismissButtonFocusNode = FocusNode();
final FocusNode showButtonFocusNode = FocusNode();
@@ -64,7 +63,7 @@ class MainWidgetState extends State<MainWidget> {
@override
Widget build(BuildContext context) {
return Scaffold(
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo')),

View File

@@ -50,10 +50,7 @@ class MainWidgetState extends State<MainWidget> {
icon: Icon(Icons.home_outlined),
label: 'Home',
),
NavigationDestination(
icon: Icon(Icons.business),
label: 'Business',
),
NavigationDestination(icon: Icon(Icons.business), label: 'Business'),
NavigationDestination(
selectedIcon: Icon(Icons.school),
icon: Icon(Icons.school_outlined),
@@ -61,20 +58,12 @@ class MainWidgetState extends State<MainWidget> {
),
],
),
body: <Widget>[
Container(
alignment: Alignment.center,
child: const Text('Page 1'),
),
Container(
alignment: Alignment.center,
child: const Text('Page 2'),
),
Container(
alignment: Alignment.center,
child: const Text('Page 3'),
),
][currentPageIndex],
body:
<Widget>[
Container(alignment: Alignment.center, child: const Text('Page 1')),
Container(alignment: Alignment.center, child: const Text('Page 2')),
Container(alignment: Alignment.center, child: const Text('Page 3')),
][currentPageIndex],
);
}
}

View File

@@ -2,12 +2,10 @@
// 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 '../utils.dart';
import 'use_cases.dart';
class ExampleDestination {
const ExampleDestination(this.label, this.icon, this.selectedIcon);
@@ -17,12 +15,9 @@ class ExampleDestination {
}
const List<ExampleDestination> destinations = <ExampleDestination>[
ExampleDestination(
'Messages', Icon(Icons.widgets_outlined), Icon(Icons.widgets)),
ExampleDestination(
'Profile', Icon(Icons.format_paint_outlined), Icon(Icons.format_paint)),
ExampleDestination(
'Settings', Icon(Icons.settings_outlined), Icon(Icons.settings)),
ExampleDestination('Messages', Icon(Icons.widgets_outlined), Icon(Icons.widgets)),
ExampleDestination('Profile', Icon(Icons.format_paint_outlined), Icon(Icons.format_paint)),
ExampleDestination('Settings', Icon(Icons.settings_outlined), Icon(Icons.settings)),
];
class NavigationDrawerUseCase extends UseCase {
@@ -40,8 +35,7 @@ class NavigationDrawerExample extends StatefulWidget {
const NavigationDrawerExample({super.key});
@override
State<NavigationDrawerExample> createState() =>
_NavigationDrawerExampleState();
State<NavigationDrawerExample> createState() => _NavigationDrawerExampleState();
}
class _NavigationDrawerExampleState extends State<NavigationDrawerExample> {
@@ -77,10 +71,7 @@ class _NavigationDrawerExampleState extends State<NavigationDrawerExample> {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text('Page Index = $screenIndex'),
ElevatedButton(
onPressed: openDrawer,
child: const Text('Open Drawer'),
),
ElevatedButton(onPressed: openDrawer, child: const Text('Open Drawer')),
],
),
),
@@ -91,24 +82,16 @@ class _NavigationDrawerExampleState extends State<NavigationDrawerExample> {
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(28, 16, 16, 10),
child: Text(
'Header',
style: Theme.of(context).textTheme.titleSmall,
),
),
...destinations.map(
(ExampleDestination destination) {
return NavigationDrawerDestination(
label: Text(destination.label),
icon: destination.icon,
selectedIcon: destination.selectedIcon,
);
},
),
const Padding(
padding: EdgeInsets.fromLTRB(28, 16, 28, 10),
child: Divider(),
child: Text('Header', style: Theme.of(context).textTheme.titleSmall),
),
...destinations.map((ExampleDestination destination) {
return NavigationDrawerDestination(
label: Text(destination.label),
icon: destination.icon,
selectedIcon: destination.selectedIcon,
);
}),
const Padding(padding: EdgeInsets.fromLTRB(28, 16, 28, 10), child: Divider()),
],
),
);

View File

@@ -47,23 +47,25 @@ class _NavRailExampleState extends State<NavRailExample> {
});
},
labelType: labelType,
leading: showLeading
? FloatingActionButton(
elevation: 0,
onPressed: () {
// Add your onPressed code here!
},
child: const Icon(Icons.add),
)
: const SizedBox(),
trailing: showTrailing
? IconButton(
onPressed: () {
// Add your onPressed code here!
},
icon: const Icon(Icons.more_horiz_rounded),
)
: const SizedBox(),
leading:
showLeading
? FloatingActionButton(
elevation: 0,
onPressed: () {
// Add your onPressed code here!
},
child: const Icon(Icons.add),
)
: const SizedBox(),
trailing:
showTrailing
? IconButton(
onPressed: () {
// Add your onPressed code here!
},
icon: const Icon(Icons.more_horiz_rounded),
)
: const SizedBox(),
destinations: const <NavigationRailDestination>[
NavigationRailDestination(
icon: Icon(Icons.favorite_border),

View File

@@ -38,9 +38,7 @@ class _MainWidgetState extends State<_MainWidget> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))
),
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
body: ListView(
children: <Widget>[
RadioListTile<SingingCharacter>(

View File

@@ -25,7 +25,6 @@ class MainWidget extends StatefulWidget {
}
class MainWidgetState extends State<MainWidget> {
String pageTitle = getUseCaseName(SnackBarUseCase());
@override
@@ -41,11 +40,9 @@ class MainWidgetState extends State<MainWidget> {
ElevatedButton(
child: const Text('Show Snackbar'),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Awesome Snackbar!'),
),
);
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('Awesome Snackbar!')));
},
),
ElevatedButton(
@@ -54,10 +51,7 @@ class MainWidgetState extends State<MainWidget> {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text('Awesome Snackbar!'),
action: SnackBarAction(
label: 'Action',
onPressed: () {},
),
action: SnackBarAction(label: 'Action', onPressed: () {}),
),
);
},

View File

@@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'use_cases.dart';
class TabBarViewUseCase extends UseCase {
@override
String get name => 'TabBarView';
@@ -18,7 +17,6 @@ class TabBarViewUseCase extends UseCase {
Widget build(BuildContext context) => const TabBarViewExample();
}
class TabBarViewExample extends StatelessWidget {
const TabBarViewExample({super.key});
@@ -32,32 +30,17 @@ class TabBarViewExample extends StatelessWidget {
title: Semantics(headingLevel: 1, child: const Text('TabBarView Sample')),
bottom: const TabBar(
tabs: <Widget>[
Tab(
icon: Icon(Icons.cloud_outlined),
text: 'Cloudy',
),
Tab(
icon: Icon(Icons.beach_access_sharp),
text: 'Rainy',
),
Tab(
icon: Icon(Icons.brightness_5_sharp),
text: 'Sunny',
),
Tab(icon: Icon(Icons.cloud_outlined), text: 'Cloudy'),
Tab(icon: Icon(Icons.beach_access_sharp), text: 'Rainy'),
Tab(icon: Icon(Icons.brightness_5_sharp), text: 'Sunny'),
],
),
),
body: const TabBarView(
children: <Widget>[
Center(
child: Text("It's cloudy here"),
),
Center(
child: Text("It's rainy here"),
),
Center(
child: Text("It's sunny here"),
),
Center(child: Text("It's cloudy here")),
Center(child: Text("It's rainy here")),
Center(child: Text("It's sunny here")),
],
),
),

View File

@@ -57,12 +57,12 @@ class MainWidgetState extends State<MainWidget> {
if (_formKey.currentState!.validate()) {
// If the form is valid, display a snackbar. In the real world,
// this might also send a request to a server.
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Form submitted')),
);
ScaffoldMessenger.of(
context,
).showSnackBar(const SnackBar(content: Text('Form submitted')));
}
},
child: const Text('Submit'),
child: const Text('Submit'),
),
),
],

View File

@@ -33,16 +33,12 @@ class _MainWidget extends StatelessWidget {
children: const <Widget>[
TextField(
key: Key('enabled password'),
decoration: InputDecoration(
labelText: 'Password',
),
decoration: InputDecoration(labelText: 'Password'),
obscureText: true,
),
TextField(
key: Key('disabled password'),
decoration: InputDecoration(
labelText: 'Password',
),
decoration: InputDecoration(labelText: 'Password'),
enabled: false,
obscureText: true,
),

View File

@@ -33,10 +33,7 @@ abstract class UseCase {
String get route;
Widget buildWithTitle(BuildContext context) {
return DynamicTitle(
title: name,
child: build(context),
);
return DynamicTitle(title: name, child: build(context));
}
Widget build(BuildContext context);

View File

@@ -9,8 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
for (final UseCase useCase in useCases) {
testWidgets('testing accessibility guideline for ${useCase.name}',
(WidgetTester tester) async {
testWidgets('testing accessibility guideline for ${useCase.name}', (WidgetTester tester) async {
await tester.pumpWidget(const App());
final ScrollController controller =
tester.state<HomePageState>(find.byType(HomePage)).scrollController;

View File

@@ -8,8 +8,7 @@ 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 {
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);

View File

@@ -35,278 +35,391 @@ import 'test_utils.dart';
void main() {
testWidgets('Has light and dark theme', (WidgetTester tester) async {
await tester.pumpWidget(const App());
final MaterialApp app =
find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
final MaterialApp app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
expect(app.theme!.brightness, equals(Brightness.light));
expect(app.darkTheme!.brightness, equals(Brightness.dark));
});
testWidgets('App can generate high-contrast color scheme',
(WidgetTester tester) async {
await tester.pumpWidget(const MediaQuery(
data: MediaQueryData(
highContrast: true,
),
child: App()));
testWidgets('App can generate high-contrast color scheme', (WidgetTester tester) async {
await tester.pumpWidget(
const MediaQuery(data: MediaQueryData(highContrast: true), child: App()),
);
final MaterialApp app =
find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
final MaterialApp app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
final DynamicScheme highContrastScheme = SchemeTonalSpot(
sourceColorHct: Hct.fromInt(const Color(0xff6750a4).value),
isDark: false,
contrastLevel: 1.0);
sourceColorHct: Hct.fromInt(const Color(0xff6750a4).value),
isDark: false,
contrastLevel: 1.0,
);
final ColorScheme appScheme = app.theme!.colorScheme;
expect(appScheme.primary.value,
MaterialDynamicColors.primary.getArgb(highContrastScheme));
expect(appScheme.onPrimary.value,
MaterialDynamicColors.onPrimary.getArgb(highContrastScheme));
expect(appScheme.primaryContainer.value,
MaterialDynamicColors.primaryContainer.getArgb(highContrastScheme));
expect(appScheme.onPrimaryContainer.value,
MaterialDynamicColors.onPrimaryContainer.getArgb(highContrastScheme));
expect(appScheme.primaryFixed.value,
MaterialDynamicColors.primaryFixed.getArgb(highContrastScheme));
expect(appScheme.primaryFixedDim.value,
MaterialDynamicColors.primaryFixedDim.getArgb(highContrastScheme));
expect(appScheme.onPrimaryFixed.value,
MaterialDynamicColors.onPrimaryFixed.getArgb(highContrastScheme));
expect(appScheme.primary.value, MaterialDynamicColors.primary.getArgb(highContrastScheme));
expect(appScheme.onPrimary.value, MaterialDynamicColors.onPrimary.getArgb(highContrastScheme));
expect(
appScheme.onPrimaryFixedVariant.value,
MaterialDynamicColors.onPrimaryFixedVariant
.getArgb(highContrastScheme));
expect(appScheme.secondary.value,
MaterialDynamicColors.secondary.getArgb(highContrastScheme));
expect(appScheme.onSecondary.value,
MaterialDynamicColors.onSecondary.getArgb(highContrastScheme));
expect(appScheme.secondaryContainer.value,
MaterialDynamicColors.secondaryContainer.getArgb(highContrastScheme));
expect(appScheme.onSecondaryContainer.value,
MaterialDynamicColors.onSecondaryContainer.getArgb(highContrastScheme));
expect(appScheme.secondaryFixed.value,
MaterialDynamicColors.secondaryFixed.getArgb(highContrastScheme));
expect(appScheme.secondaryFixedDim.value,
MaterialDynamicColors.secondaryFixedDim.getArgb(highContrastScheme));
expect(appScheme.onSecondaryFixed.value,
MaterialDynamicColors.onSecondaryFixed.getArgb(highContrastScheme));
appScheme.primaryContainer.value,
MaterialDynamicColors.primaryContainer.getArgb(highContrastScheme),
);
expect(
appScheme.onSecondaryFixedVariant.value,
MaterialDynamicColors.onSecondaryFixedVariant
.getArgb(highContrastScheme));
expect(appScheme.tertiary.value,
MaterialDynamicColors.tertiary.getArgb(highContrastScheme));
expect(appScheme.onTertiary.value,
MaterialDynamicColors.onTertiary.getArgb(highContrastScheme));
expect(appScheme.tertiaryContainer.value,
MaterialDynamicColors.tertiaryContainer.getArgb(highContrastScheme));
expect(appScheme.onTertiaryContainer.value,
MaterialDynamicColors.onTertiaryContainer.getArgb(highContrastScheme));
expect(appScheme.tertiaryFixed.value,
MaterialDynamicColors.tertiaryFixed.getArgb(highContrastScheme));
expect(appScheme.tertiaryFixedDim.value,
MaterialDynamicColors.tertiaryFixedDim.getArgb(highContrastScheme));
expect(appScheme.onTertiaryFixed.value,
MaterialDynamicColors.onTertiaryFixed.getArgb(highContrastScheme));
appScheme.onPrimaryContainer.value,
MaterialDynamicColors.onPrimaryContainer.getArgb(highContrastScheme),
);
expect(
appScheme.onTertiaryFixedVariant.value,
MaterialDynamicColors.onTertiaryFixedVariant
.getArgb(highContrastScheme));
expect(appScheme.error.value,
MaterialDynamicColors.error.getArgb(highContrastScheme));
expect(appScheme.onError.value,
MaterialDynamicColors.onError.getArgb(highContrastScheme));
expect(appScheme.errorContainer.value,
MaterialDynamicColors.errorContainer.getArgb(highContrastScheme));
expect(appScheme.onErrorContainer.value,
MaterialDynamicColors.onErrorContainer.getArgb(highContrastScheme));
expect(appScheme.background.value,
MaterialDynamicColors.background.getArgb(highContrastScheme));
expect(appScheme.onBackground.value,
MaterialDynamicColors.onBackground.getArgb(highContrastScheme));
expect(appScheme.surface.value,
MaterialDynamicColors.surface.getArgb(highContrastScheme));
expect(appScheme.surfaceDim.value,
MaterialDynamicColors.surfaceDim.getArgb(highContrastScheme));
expect(appScheme.surfaceBright.value,
MaterialDynamicColors.surfaceBright.getArgb(highContrastScheme));
appScheme.primaryFixed.value,
MaterialDynamicColors.primaryFixed.getArgb(highContrastScheme),
);
expect(
appScheme.surfaceContainerLowest.value,
MaterialDynamicColors.surfaceContainerLowest
.getArgb(highContrastScheme));
expect(appScheme.surfaceContainerLow.value,
MaterialDynamicColors.surfaceContainerLow.getArgb(highContrastScheme));
expect(appScheme.surfaceContainer.value,
MaterialDynamicColors.surfaceContainer.getArgb(highContrastScheme));
expect(appScheme.surfaceContainerHigh.value,
MaterialDynamicColors.surfaceContainerHigh.getArgb(highContrastScheme));
appScheme.primaryFixedDim.value,
MaterialDynamicColors.primaryFixedDim.getArgb(highContrastScheme),
);
expect(
appScheme.surfaceContainerHighest.value,
MaterialDynamicColors.surfaceContainerHighest
.getArgb(highContrastScheme));
expect(appScheme.onSurface.value,
MaterialDynamicColors.onSurface.getArgb(highContrastScheme));
expect(appScheme.surfaceVariant.value,
MaterialDynamicColors.surfaceVariant.getArgb(highContrastScheme));
expect(appScheme.onSurfaceVariant.value,
MaterialDynamicColors.onSurfaceVariant.getArgb(highContrastScheme));
expect(appScheme.outline.value,
MaterialDynamicColors.outline.getArgb(highContrastScheme));
expect(appScheme.outlineVariant.value,
MaterialDynamicColors.outlineVariant.getArgb(highContrastScheme));
expect(appScheme.shadow.value,
MaterialDynamicColors.shadow.getArgb(highContrastScheme));
expect(appScheme.scrim.value,
MaterialDynamicColors.scrim.getArgb(highContrastScheme));
expect(appScheme.inverseSurface.value,
MaterialDynamicColors.inverseSurface.getArgb(highContrastScheme));
expect(appScheme.onInverseSurface.value,
MaterialDynamicColors.inverseOnSurface.getArgb(highContrastScheme));
expect(appScheme.inversePrimary.value,
MaterialDynamicColors.inversePrimary.getArgb(highContrastScheme));
appScheme.onPrimaryFixed.value,
MaterialDynamicColors.onPrimaryFixed.getArgb(highContrastScheme),
);
expect(
appScheme.onPrimaryFixedVariant.value,
MaterialDynamicColors.onPrimaryFixedVariant.getArgb(highContrastScheme),
);
expect(appScheme.secondary.value, MaterialDynamicColors.secondary.getArgb(highContrastScheme));
expect(
appScheme.onSecondary.value,
MaterialDynamicColors.onSecondary.getArgb(highContrastScheme),
);
expect(
appScheme.secondaryContainer.value,
MaterialDynamicColors.secondaryContainer.getArgb(highContrastScheme),
);
expect(
appScheme.onSecondaryContainer.value,
MaterialDynamicColors.onSecondaryContainer.getArgb(highContrastScheme),
);
expect(
appScheme.secondaryFixed.value,
MaterialDynamicColors.secondaryFixed.getArgb(highContrastScheme),
);
expect(
appScheme.secondaryFixedDim.value,
MaterialDynamicColors.secondaryFixedDim.getArgb(highContrastScheme),
);
expect(
appScheme.onSecondaryFixed.value,
MaterialDynamicColors.onSecondaryFixed.getArgb(highContrastScheme),
);
expect(
appScheme.onSecondaryFixedVariant.value,
MaterialDynamicColors.onSecondaryFixedVariant.getArgb(highContrastScheme),
);
expect(appScheme.tertiary.value, MaterialDynamicColors.tertiary.getArgb(highContrastScheme));
expect(
appScheme.onTertiary.value,
MaterialDynamicColors.onTertiary.getArgb(highContrastScheme),
);
expect(
appScheme.tertiaryContainer.value,
MaterialDynamicColors.tertiaryContainer.getArgb(highContrastScheme),
);
expect(
appScheme.onTertiaryContainer.value,
MaterialDynamicColors.onTertiaryContainer.getArgb(highContrastScheme),
);
expect(
appScheme.tertiaryFixed.value,
MaterialDynamicColors.tertiaryFixed.getArgb(highContrastScheme),
);
expect(
appScheme.tertiaryFixedDim.value,
MaterialDynamicColors.tertiaryFixedDim.getArgb(highContrastScheme),
);
expect(
appScheme.onTertiaryFixed.value,
MaterialDynamicColors.onTertiaryFixed.getArgb(highContrastScheme),
);
expect(
appScheme.onTertiaryFixedVariant.value,
MaterialDynamicColors.onTertiaryFixedVariant.getArgb(highContrastScheme),
);
expect(appScheme.error.value, MaterialDynamicColors.error.getArgb(highContrastScheme));
expect(appScheme.onError.value, MaterialDynamicColors.onError.getArgb(highContrastScheme));
expect(
appScheme.errorContainer.value,
MaterialDynamicColors.errorContainer.getArgb(highContrastScheme),
);
expect(
appScheme.onErrorContainer.value,
MaterialDynamicColors.onErrorContainer.getArgb(highContrastScheme),
);
expect(
appScheme.background.value,
MaterialDynamicColors.background.getArgb(highContrastScheme),
);
expect(
appScheme.onBackground.value,
MaterialDynamicColors.onBackground.getArgb(highContrastScheme),
);
expect(appScheme.surface.value, MaterialDynamicColors.surface.getArgb(highContrastScheme));
expect(
appScheme.surfaceDim.value,
MaterialDynamicColors.surfaceDim.getArgb(highContrastScheme),
);
expect(
appScheme.surfaceBright.value,
MaterialDynamicColors.surfaceBright.getArgb(highContrastScheme),
);
expect(
appScheme.surfaceContainerLowest.value,
MaterialDynamicColors.surfaceContainerLowest.getArgb(highContrastScheme),
);
expect(
appScheme.surfaceContainerLow.value,
MaterialDynamicColors.surfaceContainerLow.getArgb(highContrastScheme),
);
expect(
appScheme.surfaceContainer.value,
MaterialDynamicColors.surfaceContainer.getArgb(highContrastScheme),
);
expect(
appScheme.surfaceContainerHigh.value,
MaterialDynamicColors.surfaceContainerHigh.getArgb(highContrastScheme),
);
expect(
appScheme.surfaceContainerHighest.value,
MaterialDynamicColors.surfaceContainerHighest.getArgb(highContrastScheme),
);
expect(appScheme.onSurface.value, MaterialDynamicColors.onSurface.getArgb(highContrastScheme));
expect(
appScheme.surfaceVariant.value,
MaterialDynamicColors.surfaceVariant.getArgb(highContrastScheme),
);
expect(
appScheme.onSurfaceVariant.value,
MaterialDynamicColors.onSurfaceVariant.getArgb(highContrastScheme),
);
expect(appScheme.outline.value, MaterialDynamicColors.outline.getArgb(highContrastScheme));
expect(
appScheme.outlineVariant.value,
MaterialDynamicColors.outlineVariant.getArgb(highContrastScheme),
);
expect(appScheme.shadow.value, MaterialDynamicColors.shadow.getArgb(highContrastScheme));
expect(appScheme.scrim.value, MaterialDynamicColors.scrim.getArgb(highContrastScheme));
expect(
appScheme.inverseSurface.value,
MaterialDynamicColors.inverseSurface.getArgb(highContrastScheme),
);
expect(
appScheme.onInverseSurface.value,
MaterialDynamicColors.inverseOnSurface.getArgb(highContrastScheme),
);
expect(
appScheme.inversePrimary.value,
MaterialDynamicColors.inversePrimary.getArgb(highContrastScheme),
);
});
testWidgets('Each A11y Assessments page has a unique page title.', (WidgetTester tester) async {
final List<MethodCall> log = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (
MethodCall methodCall,
) async {
if (methodCall.method == 'SystemChrome.setApplicationSwitcherDescription') {
log.add(methodCall);
}
return null;
});
await tester.pumpWidget(Title(
color: const Color(0xFF00FF00),
title: 'Accessibility Assessments',
child: Container(),
));
expect(log[0], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'Accessibility Assessments', 'primaryColor': 4278255360},
));
await tester.pumpWidget(
Title(color: const Color(0xFF00FF00), title: 'Accessibility Assessments', child: Container()),
);
expect(
log[0],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{
'label': 'Accessibility Assessments',
'primaryColor': 4278255360,
},
),
);
await pumpsUseCase(tester, AutoCompleteUseCase());
expect(log[2], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'AutoComplete', 'primaryColor': 4284960932},
));
expect(
log[2],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'AutoComplete', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, ActionChipUseCase());
expect(log[4], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'ActionChip', 'primaryColor': 4284960932},
));
expect(
log[4],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'ActionChip', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, BadgeUseCase());
expect(log[6], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'Badge', 'primaryColor': 4284960932},
));
expect(
log[6],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'Badge', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, CardUseCase());
expect(log[8], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'Card', 'primaryColor': 4284960932},
));
expect(
log[8],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'Card', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, CheckBoxListTile());
expect(log[10], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'CheckBoxListTile', 'primaryColor': 4284960932},
));
expect(
log[10],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'CheckBoxListTile', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, DatePickerUseCase());
expect(log[12], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'DatePicker', 'primaryColor': 4284960932},
));
expect(
log[12],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'DatePicker', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, DialogUseCase());
expect(log[14], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'Dialog', 'primaryColor': 4284960932},
));
expect(
log[14],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'Dialog', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, ExpansionTileUseCase());
expect(log[16], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'ExpansionTile', 'primaryColor': 4284960932},
));
expect(
log[16],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'ExpansionTile', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, MaterialBannerUseCase());
expect(log[18], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'MaterialBanner', 'primaryColor': 4284960932},
));
expect(
log[18],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'MaterialBanner', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, NavigationBarUseCase());
expect(log[20], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'NavigationBar', 'primaryColor': 4284960932},
));
expect(
log[20],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'NavigationBar', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, RadioListTileUseCase());
expect(log[22], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'RadioListTile', 'primaryColor': 4284960932},
));
expect(
log[22],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'RadioListTile', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, SliderUseCase());
expect(log[24], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'Slider', 'primaryColor': 4284960932},
));
expect(
log[24],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'Slider', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, SnackBarUseCase());
expect(log[26], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'SnackBar', 'primaryColor': 4284960932},
));
expect(
log[26],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'SnackBar', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, SwitchListTileUseCase());
expect(log[28], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'SwitchListTile', 'primaryColor': 4284960932},
));
expect(
log[28],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'SwitchListTile', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, TextButtonUseCase());
expect(log[30], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'TextButton', 'primaryColor': 4284960932},
));
expect(
log[30],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'TextButton', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, TextFieldUseCase());
expect(log[32], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'TextField', 'primaryColor': 4284960932},
));
expect(
log[32],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'TextField', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, TextFieldPasswordUseCase());
expect(log[34], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'TextField password', 'primaryColor': 4284960932},
));
expect(
log[34],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'TextField password', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, NavigationDrawerUseCase());
expect(log[36], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'NavigationDrawer', 'primaryColor': 4284960932},
));
expect(
log[36],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'NavigationDrawer', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, NavigationRailUseCase());
expect(log[38], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'NavigationRail', 'primaryColor': 4284960932},
));
expect(
log[38],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'NavigationRail', 'primaryColor': 4284960932},
),
);
await pumpsUseCase(tester, DrawerUseCase());
expect(log[40], isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'drawer', 'primaryColor': 4284960932},
));
expect(
log[40],
isMethodCall(
'SystemChrome.setApplicationSwitcherDescription',
arguments: <String, dynamic>{'label': 'drawer', 'primaryColor': 4284960932},
),
);
});
testWidgets('a11y assessments home page has one h1 tag', (WidgetTester tester) async {

View File

@@ -38,7 +38,9 @@ void main() {
await tester.tap(find.byType(TextButton));
final ElevatedButton showButtonFinder = tester.widget<ElevatedButton>(find.byType(ElevatedButton));
final ElevatedButton showButtonFinder = tester.widget<ElevatedButton>(
find.byType(ElevatedButton),
);
expect(showButtonFinder.focusNode!.hasFocus, isTrue);
});

View File

@@ -8,8 +8,7 @@ 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 {
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);

View File

@@ -16,14 +16,12 @@ void main() {
await tester.tapAt(tester.getCenter(find.byType(Slider)));
await tester.pumpAndSettle();
final MainWidgetState state =
tester.state<MainWidgetState>(find.byType(MainWidget));
final MainWidgetState state = tester.state<MainWidgetState>(find.byType(MainWidget));
expect(state.currentSliderValue, 60);
});
testWidgets('slider semantics wrapper exists', (WidgetTester tester) async {
await pumpsUseCase(tester, SliderUseCase());
final Finder semanticsWidget =
find.bySemanticsLabel('Accessibility Test Slider');
final Finder semanticsWidget = find.bySemanticsLabel('Accessibility Test Slider');
expect(semanticsWidget, findsOneWidget);
});

View File

@@ -7,11 +7,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Future<void> pumpsUseCase(WidgetTester tester, UseCase useCase) async {
await tester.pumpWidget(MaterialApp(
home: Builder(
builder: (BuildContext context) {
return useCase.buildWithTitle(context);
},
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (BuildContext context) {
return useCase.buildWithTitle(context);
},
),
),
));
);
}

View File

@@ -31,8 +31,7 @@ void main() {
}
});
testWidgets('text field passwords do not have hint text',
(WidgetTester tester) async {
testWidgets('text field passwords do not have hint text', (WidgetTester tester) async {
await pumpsUseCase(tester, TextFieldPasswordUseCase());
expect(find.byType(TextField), findsExactly(2));

View File

@@ -31,20 +31,21 @@ void main() {
}
});
testWidgets('font size increase does not ellipsize hint text',
(WidgetTester tester) async {
testWidgets('font size increase does not ellipsize hint text', (WidgetTester tester) async {
await pumpsUseCase(tester, TextFieldUseCase());
await tester.pumpWidget(MaterialApp(
home: MediaQuery.withClampedTextScaling(
minScaleFactor: 3,
maxScaleFactor: 3,
child: Builder(
builder: (BuildContext context) {
return TextFieldUseCase().build(context);
},
await tester.pumpWidget(
MaterialApp(
home: MediaQuery.withClampedTextScaling(
minScaleFactor: 3,
maxScaleFactor: 3,
child: Builder(
builder: (BuildContext context) {
return TextFieldUseCase().build(context);
},
),
),
),
));
);
// Test the enabled text field
{
final Finder finder = find.byKey(const Key('enabled text field'));
@@ -60,8 +61,7 @@ void main() {
await pumpsUseCase(tester, TextFieldUseCase());
const String textFieldLabel = 'Input field with suffix @gmail.com';
final Finder semanticsWidgets =
find.bySemanticsLabel(RegExp(textFieldLabel));
final Finder semanticsWidgets = find.bySemanticsLabel(RegExp(textFieldLabel));
expect(semanticsWidgets, findsExactly(2));
});