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

@@ -37,16 +37,14 @@ class _SampleAppState extends State<SampleApp> {
'effectiveness and thus to developer happiness.',
),
Headline('Bugs affecting more people are more valuable (maximize N)'),
Paragraph(
'We will make more people happier if we fix a bug experienced by more people.'
),
Paragraph('We will make more people happier if we fix a bug experienced by more people.'),
Paragraph(
'One thing to be careful about is to think about the number of '
'people we are ignoring in our metrics. For example, if we had '
'a bug that prevented our product from working on Windows, we '
'would have no Windows users, so the bug would affect nobody. '
'However, fixing the bug would enable millions of developers '
"to use our product, and that's the number that counts."
"to use our product, and that's the number that counts.",
),
Headline('Bugs with greater impact on developers are more valuable (maximize ΔH)'),
Paragraph(
@@ -54,7 +52,7 @@ class _SampleAppState extends State<SampleApp> {
'than a greater improvement. For example, if our application, '
'under certain conditions, shows a message with a typo, and '
'then crashes because of an off-by-one error in the code, '
'fixing the crash is a higher priority than fixing the typo.'
'fixing the crash is a higher priority than fixing the typo.',
),
];
@@ -72,14 +70,18 @@ class _SampleAppState extends State<SampleApp> {
icon: const Icon(Icons.density_small),
isSelected: _compact,
onPressed: () {
setState(() { _compact = true; });
setState(() {
_compact = true;
});
},
),
IconButton(
icon: const Icon(Icons.density_large),
isSelected: !_compact,
onPressed: () {
setState(() { _compact = false; });
setState(() {
_compact = false;
});
},
),
],
@@ -99,7 +101,7 @@ class _SampleAppState extends State<SampleApp> {
// widgets can read to determine what kind of child is being rendered.
class Headline extends StatelessWidget {
const Headline(this.text, { super.key });
const Headline(this.text, {super.key});
final String text;
@@ -113,7 +115,7 @@ class Headline extends StatelessWidget {
}
class Paragraph extends StatelessWidget {
const Paragraph(this.text, { super.key });
const Paragraph(this.text, {super.key});
final String text;
@@ -131,7 +133,7 @@ class Paragraph extends StatelessWidget {
// without violating the principle of agnostic composition (wherein parents should
// work with any child, not only support a fixed set of children).
class TextCategory extends ParentDataWidget<TextFlowParentData> {
const TextCategory({ super.key, required this.category, required super.child });
const TextCategory({super.key, required this.category, required super.child});
final String category;
@@ -151,7 +153,7 @@ class TextCategory extends ParentDataWidget<TextFlowParentData> {
// This is one of the two layout variants. It is a widget that defers to
// a render object defined below (RenderCompactLayout).
class CompactLayout extends MultiChildRenderObjectWidget {
const CompactLayout({ super.key, super.children });
const CompactLayout({super.key, super.children});
@override
RenderCompactLayout createRenderObject(BuildContext context) {
@@ -167,7 +169,7 @@ class CompactLayout extends MultiChildRenderObjectWidget {
// This is the other of the two layout variants. It is a widget that defers to a
// render object defined below (RenderOpenLayout).
class OpenLayout extends MultiChildRenderObjectWidget {
const OpenLayout({ super.key, super.children });
const OpenLayout({super.key, super.children});
@override
RenderOpenLayout createRenderObject(BuildContext context) {
@@ -197,9 +199,10 @@ class TextFlowParentData extends ContainerBoxParentData<RenderBox> {
// The documentation for the RenderBox class and its members provides much
// more detail on how to implement each of the methods below.
abstract class RenderTextFlow extends RenderBox
with ContainerRenderObjectMixin<RenderBox, TextFlowParentData>,
RenderBoxContainerDefaultsMixin<RenderBox, TextFlowParentData> {
RenderTextFlow({ List<RenderBox>? children }) {
with
ContainerRenderObjectMixin<RenderBox, TextFlowParentData>,
RenderBoxContainerDefaultsMixin<RenderBox, TextFlowParentData> {
RenderTextFlow({List<RenderBox>? children}) {
addAll(children);
}
@@ -354,7 +357,7 @@ abstract class RenderTextFlow extends RenderBox
// Hit testing is normal for this widget, so we defer to the default implementation.
@override
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
bool hitTestChildren(BoxHitTestResult result, {required Offset position}) {
return defaultHitTestChildren(result, position: position);
}

View File

@@ -14,9 +14,7 @@ class ExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: MyWidget(),
);
return const MaterialApp(home: MyWidget());
}
}
@@ -29,8 +27,32 @@ class MyWidget extends StatefulWidget {
class _MyWidgetState extends State<MyWidget> {
final List<String> _alphabet = <String>[
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
];
final Widget _spacer = const SizedBox.square(dimension: 10);
final UniqueKey _center = UniqueKey();
@@ -38,9 +60,9 @@ class _MyWidgetState extends State<MyWidget> {
Widget _getArrows(AxisDirection axisDirection) {
final Widget arrow = switch (axisDirection) {
AxisDirection.up => const Icon(Icons.arrow_upward_rounded),
AxisDirection.down => const Icon(Icons.arrow_downward_rounded),
AxisDirection.left => const Icon(Icons.arrow_back_rounded),
AxisDirection.up => const Icon(Icons.arrow_upward_rounded),
AxisDirection.down => const Icon(Icons.arrow_downward_rounded),
AxisDirection.left => const Icon(Icons.arrow_back_rounded),
AxisDirection.right => const Icon(Icons.arrow_forward_rounded),
};
return Flex(
@@ -88,9 +110,7 @@ class _MyWidgetState extends State<MyWidget> {
return DefaultTextStyle(
style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
child: RadioTheme(
data: RadioThemeData(
fillColor: WidgetStateProperty.all<Color>(Colors.white),
),
data: RadioThemeData(fillColor: WidgetStateProperty.all<Color>(Colors.white)),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
@@ -145,17 +165,15 @@ class _MyWidgetState extends State<MyWidget> {
child = _getLeading(constraints, isForward);
} else {
child = Container(
color: isForward
? (index.isEven ? Colors.amber[100] : Colors.amberAccent)
: (index.isEven ? Colors.green[100] : Colors.lightGreen),
color:
isForward
? (index.isEven ? Colors.amber[100] : Colors.amberAccent)
: (index.isEven ? Colors.green[100] : Colors.lightGreen),
padding: const EdgeInsets.all(8.0),
child: Center(child: Text(_alphabet[index - 1])),
);
}
return Padding(
padding: const EdgeInsets.all(8.0),
child: child,
);
return Padding(padding: const EdgeInsets.all(8.0), child: child);
},
);
},
@@ -169,10 +187,7 @@ class _MyWidgetState extends State<MyWidget> {
title: const Text('GrowthDirections'),
bottom: PreferredSize(
preferredSize: const Size.fromHeight(50),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: _getRadioRow(),
),
child: Padding(padding: const EdgeInsets.all(8.0), child: _getRadioRow()),
),
),
body: CustomScrollView(

View File

@@ -14,9 +14,7 @@ class ExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: MyWidget(),
);
return const MaterialApp(home: MyWidget());
}
}
@@ -29,8 +27,32 @@ class MyWidget extends StatefulWidget {
class _MyWidgetState extends State<MyWidget> {
final List<String> alphabet = <String>[
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
];
final Widget spacer = const SizedBox.square(dimension: 10);
ScrollDirection scrollDirection = ScrollDirection.idle;
@@ -38,9 +60,9 @@ class _MyWidgetState extends State<MyWidget> {
Widget _getArrows() {
final Widget arrow = switch (_axisDirection) {
AxisDirection.up => const Icon(Icons.arrow_upward_rounded),
AxisDirection.down => const Icon(Icons.arrow_downward_rounded),
AxisDirection.left => const Icon(Icons.arrow_back_rounded),
AxisDirection.up => const Icon(Icons.arrow_upward_rounded),
AxisDirection.down => const Icon(Icons.arrow_downward_rounded),
AxisDirection.left => const Icon(Icons.arrow_back_rounded),
AxisDirection.right => const Icon(Icons.arrow_forward_rounded),
};
return Flex(
@@ -84,9 +106,7 @@ class _MyWidgetState extends State<MyWidget> {
return DefaultTextStyle(
style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
child: RadioTheme(
data: RadioThemeData(
fillColor: WidgetStateProperty.all<Color>(Colors.white),
),
data: RadioThemeData(fillColor: WidgetStateProperty.all<Color>(Colors.white)),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
@@ -143,10 +163,7 @@ class _MyWidgetState extends State<MyWidget> {
title: const Text('ScrollDirections'),
bottom: PreferredSize(
preferredSize: const Size.fromHeight(50),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: _getRadioRow(),
),
child: Padding(padding: const EdgeInsets.all(8.0), child: _getRadioRow()),
),
),
body: NotificationListener<UserScrollNotification>(
@@ -174,10 +191,7 @@ class _MyWidgetState extends State<MyWidget> {
child: Center(child: Text(alphabet[index - 1])),
);
}
return Padding(
padding: const EdgeInsets.all(8.0),
child: child,
);
return Padding(padding: const EdgeInsets.all(8.0), child: child);
},
),
],

View File

@@ -33,9 +33,11 @@ class SliverGridDelegateWithFixedCrossAxisCountExample extends StatelessWidget {
childAspectRatio: 2,
),
children: List<Widget>.generate(20, (int i) {
return Builder(builder: (BuildContext context) {
return Text('$i');
});
return Builder(
builder: (BuildContext context) {
return Text('$i');
},
);
}),
);
}

View File

@@ -33,9 +33,11 @@ class SliverGridDelegateWithFixedCrossAxisCountExample extends StatelessWidget {
mainAxisExtent: 150.0,
),
children: List<Widget>.generate(20, (int i) {
return Builder(builder: (BuildContext context) {
return Text('$i');
});
return Builder(
builder: (BuildContext context) {
return Text('$i');
},
);
}),
);
}