Skip to content

Commit

Permalink
Auto-format Framework (flutter#160545)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: LongCatIsLooong <[email protected]>
  • Loading branch information
3 people authored Dec 19, 2024
1 parent 8e0993e commit 5491c8c
Show file tree
Hide file tree
Showing 4,411 changed files with 455,815 additions and 416,698 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ targets:
- name: Linux packages_autoroller
presubmit: false
recipe: pub_autoroller/pub_autoroller
bringup: true # https://github.com/flutter/flutter/issues/160473
# This takes a while because we need to fetch network dependencies and run
# Gradle for every android app in the repo
timeout: 45
Expand Down
9 changes: 0 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
// VSCode workspace settings that are shared among all users of this project.
// This only affects subdirectories of this project.
{
// VSCode formats files on save by default. Since Flutter source code is
// hand-formatted, the default settings are changed to prevent inadvertent
// reformatting of code.
"[dart]": {
"editor.formatOnSave": false,
"editor.formatOnType": false,
"editor.formatOnPaste": false,
},

"html.format.enable": false,
"githubPullRequests.ignoredPullRequestBranches": [
"master"
Expand Down
6 changes: 1 addition & 5 deletions dev/a11y_assessments/lib/common/dynamic_title.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
46 changes: 27 additions & 19 deletions dev/a11y_assessments/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
7 changes: 2 additions & 5 deletions dev/a11y_assessments/lib/use_cases/action_chip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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')),
],
),
),
Expand Down
97 changes: 46 additions & 51 deletions dev/a11y_assessments/lib/use_cases/app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
),
],
),
TextButton(
onPressed: () {},
child: const Text('Action 2'),
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')),
],
),
],
),
][currentIndex],
][currentIndex],
body: ListView(
children: <Widget>[
RadioListTile<int>(
Expand Down
18 changes: 7 additions & 11 deletions dev/a11y_assessments/lib/use_cases/auto_complete.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 == '') {
Expand Down
6 changes: 1 addition & 5 deletions dev/a11y_assessments/lib/use_cases/badge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
),
Expand Down
7 changes: 1 addition & 6 deletions dev/a11y_assessments/lib/use_cases/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'))),
],
),
),
Expand Down
4 changes: 1 addition & 3 deletions dev/a11y_assessments/lib/use_cases/check_box_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 8 additions & 8 deletions dev/a11y_assessments/lib/use_cases/date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class _MainWidget extends StatefulWidget {
}

class _MainWidgetState extends State<_MainWidget> {

String pageTitle = getUseCaseName(DatePickerUseCase());

@override
Expand All @@ -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'),
),
),
Expand Down
Loading

0 comments on commit 5491c8c

Please sign in to comment.