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:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -32,7 +32,6 @@ class _HomePage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomePageState extends State<_HomePage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -73,23 +72,17 @@ class _PageTwoState extends State<_PageTwo> {
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Are you sure?'),
|
||||
content: const Text(
|
||||
'Are you sure you want to leave this page?',
|
||||
),
|
||||
content: const Text('Are you sure you want to leave this page?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
textStyle: Theme.of(context).textTheme.labelLarge,
|
||||
),
|
||||
style: TextButton.styleFrom(textStyle: Theme.of(context).textTheme.labelLarge),
|
||||
child: const Text('Nevermind'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, false);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
textStyle: Theme.of(context).textTheme.labelLarge,
|
||||
),
|
||||
style: TextButton.styleFrom(textStyle: Theme.of(context).textTheme.labelLarge),
|
||||
child: const Text('Leave'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
|
||||
@@ -21,9 +21,7 @@ class NavigatorPopHandlerApp extends StatelessWidget {
|
||||
'/two' => MaterialPageRoute<FormData>(
|
||||
builder: (BuildContext context) => const _PageTwo(),
|
||||
),
|
||||
_ => MaterialPageRoute<void>(
|
||||
builder: (BuildContext context) => const _HomePage(),
|
||||
),
|
||||
_ => MaterialPageRoute<void>(builder: (BuildContext context) => const _HomePage()),
|
||||
};
|
||||
},
|
||||
);
|
||||
@@ -53,8 +51,7 @@ class _HomePageState extends State<_HomePage> {
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
final FormData formData =
|
||||
await Navigator.of(context).pushNamed<FormData?>('/two')
|
||||
?? const FormData();
|
||||
await Navigator.of(context).pushNamed<FormData?>('/two') ?? const FormData();
|
||||
if (formData != _formData) {
|
||||
setState(() {
|
||||
_formData = formData;
|
||||
@@ -81,23 +78,17 @@ class _PopScopeWrapper extends StatelessWidget {
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Are you sure?'),
|
||||
content: const Text(
|
||||
'Are you sure you want to leave this page?',
|
||||
),
|
||||
content: const Text('Are you sure you want to leave this page?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
textStyle: Theme.of(context).textTheme.labelLarge,
|
||||
),
|
||||
style: TextButton.styleFrom(textStyle: Theme.of(context).textTheme.labelLarge),
|
||||
child: const Text('Never mind'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, false);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
textStyle: Theme.of(context).textTheme.labelLarge,
|
||||
),
|
||||
style: TextButton.styleFrom(textStyle: Theme.of(context).textTheme.labelLarge),
|
||||
child: const Text('Leave'),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, true);
|
||||
@@ -134,11 +125,8 @@ class _PageTwo extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const _PopScopeWrapper(
|
||||
child: _PageTwoBody(),
|
||||
);
|
||||
return const _PopScopeWrapper(child: _PageTwoBody());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class _PageTwoBody extends StatefulWidget {
|
||||
@@ -163,23 +151,15 @@ class _PageTwoBodyState extends State<_PageTwoBody> {
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Enter your name.',
|
||||
),
|
||||
decoration: const InputDecoration(hintText: 'Enter your name.'),
|
||||
onChanged: (String value) {
|
||||
_formData = _formData.copyWith(
|
||||
name: value,
|
||||
);
|
||||
_formData = _formData.copyWith(name: value);
|
||||
},
|
||||
),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Enter your favorite food.',
|
||||
),
|
||||
decoration: const InputDecoration(hintText: 'Enter your favorite food.'),
|
||||
onChanged: (String value) {
|
||||
_formData = _formData.copyWith(
|
||||
favoriteFood: value,
|
||||
);
|
||||
_formData = _formData.copyWith(favoriteFood: value);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -200,19 +180,13 @@ class _PageTwoBodyState extends State<_PageTwoBody> {
|
||||
|
||||
@immutable
|
||||
class FormData {
|
||||
const FormData({
|
||||
this.name = '',
|
||||
this.favoriteFood = '',
|
||||
});
|
||||
const FormData({this.name = '', this.favoriteFood = ''});
|
||||
|
||||
final String name;
|
||||
final String favoriteFood;
|
||||
|
||||
FormData copyWith({String? name, String? favoriteFood}) {
|
||||
return FormData(
|
||||
name: name ?? this.name,
|
||||
favoriteFood: favoriteFood ?? this.favoriteFood,
|
||||
);
|
||||
return FormData(name: name ?? this.name, favoriteFood: favoriteFood ?? this.favoriteFood);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -223,9 +197,7 @@ class FormData {
|
||||
if (other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
return other is FormData
|
||||
&& other.name == name
|
||||
&& other.favoriteFood == favoriteFood;
|
||||
return other is FormData && other.name == name && other.favoriteFood == favoriteFood;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user