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

@@ -15,7 +15,8 @@ class ComplexLayoutApp extends StatefulWidget {
@override
ComplexLayoutAppState createState() => ComplexLayoutAppState();
static ComplexLayoutAppState? of(BuildContext context) => context.findAncestorStateOfType<ComplexLayoutAppState>();
static ComplexLayoutAppState? of(BuildContext context) =>
context.findAncestorStateOfType<ComplexLayoutAppState>();
}
class ComplexLayoutAppState extends State<ComplexLayoutApp> {
@@ -24,7 +25,11 @@ class ComplexLayoutAppState extends State<ComplexLayoutApp> {
return MaterialApp(
theme: lightTheme ? ThemeData.light() : ThemeData.dark(),
title: 'Advanced Layout',
home: scrollMode == ScrollMode.complex ? ComplexLayout(badScroll: widget.badScroll) : const TileScrollLayout());
home:
scrollMode == ScrollMode.complex
? ComplexLayout(badScroll: widget.badScroll)
: const TileScrollLayout(),
);
}
bool _lightTheme = true;
@@ -51,7 +56,7 @@ class ComplexLayoutAppState extends State<ComplexLayoutApp> {
}
class TileScrollLayout extends StatelessWidget {
const TileScrollLayout({ super.key });
const TileScrollLayout({super.key});
@override
Widget build(BuildContext context) {
@@ -77,14 +82,15 @@ class TileScrollLayout extends StatelessWidget {
}
class ComplexLayout extends StatefulWidget {
const ComplexLayout({ super.key, required this.badScroll });
const ComplexLayout({super.key, required this.badScroll});
final bool badScroll;
@override
ComplexLayoutState createState() => ComplexLayoutState();
static ComplexLayoutState? of(BuildContext context) => context.findAncestorStateOfType<ComplexLayoutState>();
static ComplexLayoutState? of(BuildContext context) =>
context.findAncestorStateOfType<ComplexLayoutState>();
}
class ComplexLayoutState extends State<ComplexLayout> {
@@ -92,7 +98,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
Widget build(BuildContext context) {
Widget body = ListView.builder(
key: const Key('complex-scroll'), // this key is used by the driver test
controller: ScrollController(), // So that the scroll offset can be tracked
controller: ScrollController(), // So that the scroll offset can be tracked
itemCount: widget.badScroll ? 500 : null,
shrinkWrap: widget.badScroll,
itemBuilder: (BuildContext context, int index) {
@@ -104,10 +110,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
},
);
if (widget.badScroll) {
body = ListView(
key: const Key('complex-scroll-bad'),
children: <Widget>[body],
);
body = ListView(key: const Key('complex-scroll-bad'), children: <Widget>[body]);
}
return Scaffold(
@@ -124,12 +127,7 @@ class ComplexLayoutState extends State<ComplexLayout> {
const TopBarMenu(),
],
),
body: Column(
children: <Widget>[
Expanded(child: body),
const BottomBar(),
],
),
body: Column(children: <Widget>[Expanded(child: body), const BottomBar()]),
drawer: const GalleryDrawer(),
);
}
@@ -141,49 +139,52 @@ class TopBarMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
return PopupMenuButton<String>(
onSelected: (String value) { print('Selected: $value'); },
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
const PopupMenuItem<String>(
value: 'Friends',
child: MenuItemWithIcon(Icons.people, 'Friends', '5 new'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.event, 'Events', '12 upcoming'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.group, 'Groups', '14'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.image, 'Pictures', '12'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.near_me, 'Nearby', '33'),
),
const PopupMenuItem<String>(
value: 'Friends',
child: MenuItemWithIcon(Icons.people, 'Friends', '5'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.event, 'Events', '12'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.group, 'Groups', '14'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.image, 'Pictures', '12'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.near_me, 'Nearby', '33'),
),
],
onSelected: (String value) {
print('Selected: $value');
},
itemBuilder:
(BuildContext context) => <PopupMenuItem<String>>[
const PopupMenuItem<String>(
value: 'Friends',
child: MenuItemWithIcon(Icons.people, 'Friends', '5 new'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.event, 'Events', '12 upcoming'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.group, 'Groups', '14'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.image, 'Pictures', '12'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.near_me, 'Nearby', '33'),
),
const PopupMenuItem<String>(
value: 'Friends',
child: MenuItemWithIcon(Icons.people, 'Friends', '5'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.event, 'Events', '12'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.group, 'Groups', '14'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.image, 'Pictures', '12'),
),
const PopupMenuItem<String>(
value: 'Events',
child: MenuItemWithIcon(Icons.near_me, 'Nearby', '33'),
),
],
);
}
}
@@ -200,10 +201,7 @@ class MenuItemWithIcon extends StatelessWidget {
return Row(
children: <Widget>[
Icon(icon),
Padding(
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
child: Text(title),
),
Padding(padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: Text(title)),
Text(subtitle, style: Theme.of(context).textTheme.bodySmall),
],
);
@@ -223,10 +221,7 @@ class FancyImageItem extends StatelessWidget {
const ItemDescription(),
const ItemImageBox(),
const InfoBar(),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: Divider(),
),
const Padding(padding: EdgeInsets.symmetric(horizontal: 8.0), child: Divider()),
const IconBar(),
const FatDivider(),
],
@@ -245,10 +240,7 @@ class FancyGalleryItem extends StatelessWidget {
const UserHeader('Ali Connors'),
ItemGalleryBox(index),
const InfoBar(),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: Divider(),
),
const Padding(padding: EdgeInsets.symmetric(horizontal: 8.0), child: Divider()),
const IconBar(),
const FatDivider(),
],
@@ -306,7 +298,9 @@ class IconWithText extends StatelessWidget {
children: <Widget>[
IconButton(
icon: Icon(icon),
onPressed: () { print('Pressed $title button'); },
onPressed: () {
print('Pressed $title button');
},
),
Text(title),
],
@@ -348,10 +342,7 @@ class FatDivider extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 8.0,
color: Theme.of(context).dividerColor,
);
return Container(height: 8.0, color: Theme.of(context).dividerColor);
}
}
@@ -379,18 +370,24 @@ class UserHeader extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
RichText(text: TextSpan(
style: Theme.of(context).textTheme.bodyMedium,
children: <TextSpan>[
TextSpan(text: userName, style: const TextStyle(fontWeight: FontWeight.bold)),
const TextSpan(text: ' shared a new '),
const TextSpan(text: 'photo', style: TextStyle(fontWeight: FontWeight.bold)),
],
)),
RichText(
text: TextSpan(
style: Theme.of(context).textTheme.bodyMedium,
children: <TextSpan>[
TextSpan(text: userName, style: const TextStyle(fontWeight: FontWeight.bold)),
const TextSpan(text: ' shared a new '),
const TextSpan(text: 'photo', style: TextStyle(fontWeight: FontWeight.bold)),
],
),
),
Row(
children: <Widget>[
Text('Yesterday at 11:55 • ', style: Theme.of(context).textTheme.bodySmall),
Icon(Icons.people, size: 16.0, color: Theme.of(context).textTheme.bodySmall!.color),
Icon(
Icons.people,
size: 16.0,
color: Theme.of(context).textTheme.bodySmall!.color,
),
],
),
],
@@ -410,7 +407,9 @@ class ItemDescription extends StatelessWidget {
Widget build(BuildContext context) {
return const Padding(
padding: EdgeInsets.all(8.0),
child: Text('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'),
child: Text(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
),
);
}
}
@@ -431,7 +430,9 @@ class ItemImageBox extends StatelessWidget {
const SizedBox(
height: 230.0,
child: Image(
image: AssetImage('packages/flutter_gallery_assets/places/india_chettinad_silk_maker.png')
image: AssetImage(
'packages/flutter_gallery_assets/places/india_chettinad_silk_maker.png',
),
),
),
Theme(
@@ -441,11 +442,15 @@ class ItemImageBox extends StatelessWidget {
children: <Widget>[
IconButton(
icon: const Icon(Icons.edit),
onPressed: () { print('Pressed edit button'); },
onPressed: () {
print('Pressed edit button');
},
),
IconButton(
icon: const Icon(Icons.zoom_in),
onPressed: () { print('Pressed zoom button'); },
onPressed: () {
print('Pressed zoom button');
},
),
],
),
@@ -463,9 +468,7 @@ class ItemImageBox extends StatelessWidget {
text: const TextSpan(
style: TextStyle(color: Colors.white),
children: <TextSpan>[
TextSpan(
text: 'Photo by '
),
TextSpan(text: 'Photo by '),
TextSpan(
style: TextStyle(fontWeight: FontWeight.bold),
text: 'Chris Godley',
@@ -476,8 +479,7 @@ class ItemImageBox extends StatelessWidget {
),
),
],
)
,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
@@ -503,9 +505,7 @@ class ItemGalleryBox extends StatelessWidget {
@override
Widget build(BuildContext context) {
final List<String> tabNames = <String>[
'A', 'B', 'C', 'D',
];
final List<String> tabNames = <String>['A', 'B', 'C', 'D'];
return SizedBox(
height: 200.0,
@@ -515,46 +515,56 @@ class ItemGalleryBox extends StatelessWidget {
children: <Widget>[
Expanded(
child: TabBarView(
children: tabNames.map<Widget>((String tabName) {
return Container(
key: PageStorageKey<String>(tabName),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
child: Column(
children: <Widget>[
Expanded(
child: ColoredBox(
color: Theme.of(context).primaryColor,
child: Center(
child: Text(tabName, style: Theme.of(context).textTheme.headlineSmall!.copyWith(color: Colors.white)),
),
),
),
Row(
children:
tabNames.map<Widget>((String tabName) {
return Container(
key: PageStorageKey<String>(tabName),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
child: Column(
children: <Widget>[
IconButton(
icon: const Icon(Icons.share),
onPressed: () { print('Pressed share'); },
),
IconButton(
icon: const Icon(Icons.event),
onPressed: () { print('Pressed event'); },
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text('This is item $tabName'),
child: ColoredBox(
color: Theme.of(context).primaryColor,
child: Center(
child: Text(
tabName,
style: Theme.of(
context,
).textTheme.headlineSmall!.copyWith(color: Colors.white),
),
),
),
),
Row(
children: <Widget>[
IconButton(
icon: const Icon(Icons.share),
onPressed: () {
print('Pressed share');
},
),
IconButton(
icon: const Icon(Icons.event),
onPressed: () {
print('Pressed event');
},
),
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text('This is item $tabName'),
),
),
],
),
],
),
],
),
),
),
),
);
}).toList(),
);
}).toList(),
),
),
const TabPageSelector(),
@@ -572,11 +582,7 @@ class BottomBar extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: Theme.of(context).dividerColor,
),
),
border: Border(top: BorderSide(color: Theme.of(context).dividerColor)),
),
child: const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -606,7 +612,9 @@ class BottomBarButton extends StatelessWidget {
children: <Widget>[
IconButton(
icon: Icon(icon),
onPressed: () { print('Pressed: $title'); },
onPressed: () {
print('Pressed: $title');
},
),
Text(title, style: Theme.of(context).textTheme.bodySmall),
],
@@ -616,7 +624,7 @@ class BottomBarButton extends StatelessWidget {
}
class GalleryDrawer extends StatelessWidget {
const GalleryDrawer({ super.key });
const GalleryDrawer({super.key});
void _changeTheme(BuildContext context, bool value) {
ComplexLayoutApp.of(context)?.lightTheme = value;
@@ -642,31 +650,42 @@ class GalleryDrawer extends StatelessWidget {
key: const Key('scroll-switcher'),
title: const Text('Scroll Mode'),
onTap: () {
_changeScrollMode(context, currentMode == ScrollMode.complex ? ScrollMode.tile : ScrollMode.complex);
Navigator.pop(context);
_changeScrollMode(
context,
currentMode == ScrollMode.complex ? ScrollMode.tile : ScrollMode.complex,
);
Navigator.pop(context);
},
trailing: Text(currentMode == ScrollMode.complex ? 'Tile' : 'Complex'),
),
ListTile(
leading: const Icon(Icons.brightness_5),
title: const Text('Light'),
onTap: () { _changeTheme(context, true); },
onTap: () {
_changeTheme(context, true);
},
selected: ComplexLayoutApp.of(context)!.lightTheme,
trailing: Radio<bool>(
value: true,
groupValue: ComplexLayoutApp.of(context)!.lightTheme,
onChanged: (bool? value) { _changeTheme(context, value!); },
onChanged: (bool? value) {
_changeTheme(context, value!);
},
),
),
ListTile(
leading: const Icon(Icons.brightness_7),
title: const Text('Dark'),
onTap: () { _changeTheme(context, false); },
onTap: () {
_changeTheme(context, false);
},
selected: !ComplexLayoutApp.of(context)!.lightTheme,
trailing: Radio<bool>(
value: false,
groupValue: ComplexLayoutApp.of(context)!.lightTheme,
onChanged: (bool? value) { _changeTheme(context, value!); },
onChanged: (bool? value) {
_changeTheme(context, value!);
},
),
),
const Divider(),
@@ -674,10 +693,14 @@ class GalleryDrawer extends StatelessWidget {
leading: const Icon(Icons.hourglass_empty),
title: const Text('Animate Slowly'),
selected: timeDilation != 1.0,
onTap: () { ComplexLayoutApp.of(context)!.toggleAnimationSpeed(); },
onTap: () {
ComplexLayoutApp.of(context)!.toggleAnimationSpeed();
},
trailing: Checkbox(
value: timeDilation != 1.0,
onChanged: (bool? value) { ComplexLayoutApp.of(context)!.toggleAnimationSpeed(); },
onChanged: (bool? value) {
ComplexLayoutApp.of(context)!.toggleAnimationSpeed();
},
),
),
],
@@ -694,10 +717,7 @@ class FancyDrawerHeader extends StatelessWidget {
return Container(
color: Colors.purple,
height: 200.0,
child: const SafeArea(
bottom: false,
child: Placeholder(),
),
child: const SafeArea(bottom: false, child: Placeholder()),
);
}
}