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

@@ -13,28 +13,32 @@ class MyDataSource extends DataTableSource {
@override
DataRow? getRow(int index) {
switch (index) {
case 0: return const DataRow(
cells: <DataCell>[
DataCell(Text('Sarah')),
DataCell(Text('19')),
DataCell(Text('Student')),
],
);
case 1: return const DataRow(
cells: <DataCell>[
DataCell(Text('Janine')),
DataCell(Text('43')),
DataCell(Text('Professor')),
],
);
case 2: return const DataRow(
cells: <DataCell>[
DataCell(Text('William')),
DataCell(Text('27')),
DataCell(Text('Associate Professor')),
],
);
default: return null;
case 0:
return const DataRow(
cells: <DataCell>[
DataCell(Text('Sarah')),
DataCell(Text('19')),
DataCell(Text('Student')),
],
);
case 1:
return const DataRow(
cells: <DataCell>[
DataCell(Text('Janine')),
DataCell(Text('43')),
DataCell(Text('Professor')),
],
);
case 2:
return const DataRow(
cells: <DataCell>[
DataCell(Text('William')),
DataCell(Text('27')),
DataCell(Text('Associate Professor')),
],
);
default:
return null;
}
}
@@ -55,10 +59,7 @@ class DataTableExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: SingleChildScrollView(
padding: EdgeInsets.all(12.0),
child: DataTableExample(),
),
home: SingleChildScrollView(padding: EdgeInsets.all(12.0), child: DataTableExample()),
);
}
}
@@ -70,15 +71,9 @@ class DataTableExample extends StatelessWidget {
Widget build(BuildContext context) {
return PaginatedDataTable(
columns: const <DataColumn>[
DataColumn(
label: Text('Name'),
),
DataColumn(
label: Text('Age'),
),
DataColumn(
label: Text('Role'),
),
DataColumn(label: Text('Name')),
DataColumn(label: Text('Age')),
DataColumn(label: Text('Role')),
],
source: dataSource,
);

View File

@@ -7,15 +7,16 @@ import 'package:flutter/material.dart';
/// Flutter code sample for [PaginatedDataTable].
class MyDataSource extends DataTableSource {
static const List<int> _displayIndexToRawIndex = <int>[ 0, 3, 4, 5, 6 ];
static const List<int> _displayIndexToRawIndex = <int>[0, 3, 4, 5, 6];
late List<List<Comparable<Object>>> sortedData;
void setData(List<List<Comparable<Object>>> rawData, int sortColumn, bool sortAscending) {
sortedData = rawData.toList()..sort((List<Comparable<Object>> a, List<Comparable<Object>> b) {
final Comparable<Object> cellA = a[_displayIndexToRawIndex[sortColumn]];
final Comparable<Object> cellB = b[_displayIndexToRawIndex[sortColumn]];
return cellA.compareTo(cellB) * (sortAscending ? 1 : -1);
});
sortedData =
rawData.toList()..sort((List<Comparable<Object>> a, List<Comparable<Object>> b) {
final Comparable<Object> cellA = a[_displayIndexToRawIndex[sortColumn]];
final Comparable<Object> cellB = b[_displayIndexToRawIndex[sortColumn]];
return cellA.compareTo(cellB) * (sortAscending ? 1 : -1);
});
notifyListeners();
}
@@ -25,7 +26,8 @@ class MyDataSource extends DataTableSource {
static DataCell cellFor(Object data) {
String value;
if (data is DateTime) {
value = '${data.year}-${data.month.toString().padLeft(2, '0')}-${data.day.toString().padLeft(2, '0')}';
value =
'${data.year}-${data.month.toString().padLeft(2, '0')}-${data.day.toString().padLeft(2, '0')}';
} else {
value = data.toString();
}
@@ -61,10 +63,7 @@ class DataTableExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: SingleChildScrollView(
padding: EdgeInsets.all(12.0),
child: DataTableExample(),
),
home: SingleChildScrollView(padding: EdgeInsets.all(12.0), child: DataTableExample()),
);
}
}
@@ -77,8 +76,7 @@ class DataTableExample extends StatefulWidget {
}
class _DataTableExampleState extends State<DataTableExample> {
final MyDataSource dataSource = MyDataSource()
..setData(episodes, 0, true);
final MyDataSource dataSource = MyDataSource()..setData(episodes, 0, true);
int _columnIndex = 0;
bool _columnAscending = true;
@@ -97,26 +95,11 @@ class _DataTableExampleState extends State<DataTableExample> {
sortColumnIndex: _columnIndex,
sortAscending: _columnAscending,
columns: <DataColumn>[
DataColumn(
label: const Text('Episode'),
onSort: _sort,
),
DataColumn(
label: const Text('Title'),
onSort: _sort,
),
DataColumn(
label: const Text('Director'),
onSort: _sort,
),
DataColumn(
label: const Text('Writer(s)'),
onSort: _sort,
),
DataColumn(
label: const Text('Air Date'),
onSort: _sort,
),
DataColumn(label: const Text('Episode'), onSort: _sort),
DataColumn(label: const Text('Title'), onSort: _sort),
DataColumn(label: const Text('Director'), onSort: _sort),
DataColumn(label: const Text('Writer(s)'), onSort: _sort),
DataColumn(label: const Text('Air Date'), onSort: _sort),
],
source: dataSource,
);
@@ -277,15 +260,7 @@ final List<List<Comparable<Object>>> episodes = <List<Comparable<Object>>>[
'Kathryn Lyn, Bill Wolkoff',
DateTime(2023, 7, 22),
],
<Comparable<Object>>[
18,
2,
8,
'Under the Cloak of War',
'',
'Davy Perez',
DateTime(2023, 7, 27),
],
<Comparable<Object>>[18, 2, 8, 'Under the Cloak of War', '', 'Davy Perez', DateTime(2023, 7, 27)],
<Comparable<Object>>[
19,
2,
@@ -295,13 +270,5 @@ final List<List<Comparable<Object>>> episodes = <List<Comparable<Object>>>[
'Dana Horgan, Bill Wolkoff',
DateTime(2023, 8, 3),
],
<Comparable<Object>>[
20,
2,
10,
'Hegemony',
'',
'Henry Alonso Myers',
DateTime(2023, 8, 10),
],
<Comparable<Object>>[20, 2, 10, 'Hegemony', '', 'Henry Alonso Myers', DateTime(2023, 8, 10)],
];