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

@@ -11,7 +11,7 @@ void main() {
}
class TextButtonExampleApp extends StatefulWidget {
const TextButtonExampleApp({ super.key });
const TextButtonExampleApp({super.key});
@override
State<TextButtonExampleApp> createState() => _TextButtonExampleAppState();
@@ -32,7 +32,9 @@ class _TextButtonExampleAppState extends State<TextButtonExampleApp> {
child: TextButtonExample(
darkMode: darkMode,
updateDarkMode: (bool value) {
setState(() { darkMode = value; });
setState(() {
darkMode = value;
});
},
),
),
@@ -42,7 +44,7 @@ class _TextButtonExampleAppState extends State<TextButtonExampleApp> {
}
class TextButtonExample extends StatefulWidget {
const TextButtonExample({ super.key, required this.darkMode, required this.updateDarkMode });
const TextButtonExample({super.key, required this.darkMode, required this.updateDarkMode});
final bool darkMode;
final ValueChanged<bool> updateDarkMode;
@@ -97,8 +99,16 @@ class _TextButtonExampleState extends State<TextButtonExample> {
// the current dark/light mode. Used to define TextButton #7's
// gradients.
final (Color color1, Color color2, Color color3) = switch (colorScheme.brightness) {
Brightness.light => (Colors.blue.withOpacity(1.0), Colors.orange.withOpacity(1.0), Colors.yellow.withOpacity(1.0)),
Brightness.dark => (Colors.purple.withOpacity(1.0), Colors.cyan.withOpacity(1.0), Colors.yellow.withOpacity(1.0)),
Brightness.light => (
Colors.blue.withOpacity(1.0),
Colors.orange.withOpacity(1.0),
Colors.yellow.withOpacity(1.0),
),
Brightness.dark => (
Colors.purple.withOpacity(1.0),
Colors.cyan.withOpacity(1.0),
Colors.yellow.withOpacity(1.0),
),
};
// This gradient's appearance reflects the button's state.
@@ -125,16 +135,10 @@ class _TextButtonExampleState extends State<TextButtonExample> {
// Card are broken out below.
final List<Widget> columnOneButtons = <Widget>[
TextButton(
onPressed: () {},
child: const Text('Enabled'),
),
TextButton(onPressed: () {}, child: const Text('Enabled')),
verticalSpacer,
const TextButton(
onPressed: null,
child: Text('Disabled'),
),
const TextButton(onPressed: null, child: Text('Disabled')),
verticalSpacer,
TextButton.icon(
@@ -159,7 +163,7 @@ class _TextButtonExampleState extends State<TextButtonExample> {
foregroundColor: colorScheme.onError,
backgroundColor: colorScheme.error,
),
onPressed: () { },
onPressed: () {},
icon: const Icon(Icons.access_alarm),
label: const Text('TextButton.icon #2'),
),
@@ -176,13 +180,10 @@ class _TextButtonExampleState extends State<TextButtonExample> {
style: TextButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: const BorderRadius.all(Radius.circular(8)),
side: BorderSide(
color: colorScheme.primary,
width: 5,
),
side: BorderSide(color: colorScheme.primary, width: 5),
),
),
onPressed: () { },
onPressed: () {},
child: const Text('TextButton #3'),
),
verticalSpacer,
@@ -195,10 +196,8 @@ class _TextButtonExampleState extends State<TextButtonExample> {
// If the overlayColor was Colors.transparent, no splash
// or highlights would be shown.
TextButton(
style: TextButton.styleFrom(
overlayColor: Colors.yellow,
),
onPressed: () { },
style: TextButton.styleFrom(overlayColor: Colors.yellow),
onPressed: () {},
child: const Text('TextButton #4'),
),
];
@@ -219,10 +218,7 @@ class _TextButtonExampleState extends State<TextButtonExample> {
return LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: <Color>[
colorScheme.primary,
colorScheme.onPrimary,
],
colors: <Color>[colorScheme.primary, colorScheme.onPrimary],
).createShader(bounds);
},
blendMode: BlendMode.srcATop,
@@ -230,7 +226,7 @@ class _TextButtonExampleState extends State<TextButtonExample> {
);
},
),
onPressed: () { },
onPressed: () {},
child: const Text('TextButton #5'),
),
verticalSpacer,
@@ -251,15 +247,16 @@ class _TextButtonExampleState extends State<TextButtonExample> {
foregroundBuilder: (BuildContext context, Set<WidgetState> states, Widget? child) {
return DecoratedBox(
decoration: BoxDecoration(
border: states.contains(WidgetState.hovered)
? Border(bottom: BorderSide(color: colorScheme.primary))
: const Border(), // essentially "no border"
border:
states.contains(WidgetState.hovered)
? Border(bottom: BorderSide(color: colorScheme.primary))
: const Border(), // essentially "no border"
),
child: child,
);
},
),
onPressed: () { },
onPressed: () {},
child: const Text('TextButton #6'),
),
verticalSpacer,
@@ -318,10 +315,7 @@ class _TextButtonExampleState extends State<TextButtonExample> {
backgroundBuilder: (BuildContext context, Set<WidgetState> states, Widget? child) {
return Ink(
decoration: const BoxDecoration(
image: DecorationImage(
image: grassImage,
fit: BoxFit.cover,
),
image: DecorationImage(image: grassImage, fit: BoxFit.cover),
),
child: child,
);
@@ -351,10 +345,14 @@ class _TextButtonExampleState extends State<TextButtonExample> {
late final Future<void> thisAction;
thisAction = Future<void>.delayed(const Duration(seconds: 1), () {
if (currentAction == thisAction) {
setState(() { currentAction = null; });
setState(() {
currentAction = null;
});
}
});
setState(() { currentAction = thisAction; });
setState(() {
currentAction = thisAction;
});
},
style: TextButton.styleFrom(
overlayColor: Colors.transparent,
@@ -374,12 +372,7 @@ class _TextButtonExampleState extends State<TextButtonExample> {
height: 64,
duration: const Duration(milliseconds: 300),
curve: Curves.fastOutSlowIn,
decoration: BoxDecoration(
image: DecorationImage(
image: image,
fit: BoxFit.contain,
),
),
decoration: BoxDecoration(image: DecorationImage(image: image, fit: BoxFit.contain)),
);
},
),
@@ -388,7 +381,7 @@ class _TextButtonExampleState extends State<TextButtonExample> {
];
return Row(
children: <Widget> [
children: <Widget>[
// The dark/light and LTR/RTL switches. We use the updateDarkMode function
// provided by the parent TextButtonExampleApp to rebuild the MaterialApp
// in the appropriate dark/light ThemeMdoe. The directionality of the rest
@@ -407,7 +400,7 @@ class _TextButtonExampleState extends State<TextButtonExample> {
horizontalSpacer,
Expanded(
child: Scrollbar(
child: Scrollbar(
controller: scrollController,
thumbVisibility: true,
child: SingleChildScrollView(
@@ -419,17 +412,13 @@ class _TextButtonExampleState extends State<TextButtonExample> {
children: <Widget>[
Directionality(
textDirection: textDirection,
child: Column(
children: columnOneButtons,
),
child: Column(children: columnOneButtons),
),
horizontalSpacer,
Directionality(
textDirection: textDirection,
child: Column(
children: columnTwoButtons
),
child: Column(children: columnTwoButtons),
),
horizontalSpacer,
],
@@ -448,7 +437,7 @@ class TextButtonExampleSwitches extends StatelessWidget {
required this.darkMode,
required this.updateDarkMode,
required this.textDirection,
required this.updateRTL
required this.updateRTL,
});
final bool darkMode;
@@ -468,10 +457,7 @@ class TextButtonExampleSwitches extends StatelessWidget {
children: <Widget>[
const Expanded(child: Text('Dark Mode')),
const SizedBox(width: 4),
Switch(
value: darkMode,
onChanged: updateDarkMode,
),
Switch(value: darkMode, onChanged: updateDarkMode),
],
),
const SizedBox(height: 16),
@@ -479,10 +465,7 @@ class TextButtonExampleSwitches extends StatelessWidget {
children: <Widget>[
const Expanded(child: Text('RTL Text')),
const SizedBox(width: 4),
Switch(
value: textDirection == TextDirection.rtl,
onChanged: updateRTL,
),
Switch(value: textDirection == TextDirection.rtl, onChanged: updateRTL),
],
),
],

View File

@@ -34,7 +34,9 @@ class _SelectableButtonState extends State<SelectableButton> {
@override
void initState() {
super.initState();
statesController = WidgetStatesController(<WidgetState>{if (widget.selected) WidgetState.selected});
statesController = WidgetStatesController(<WidgetState>{
if (widget.selected) WidgetState.selected,
});
}
@override