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
@@ -17,9 +17,7 @@ class SwitchApp extends StatelessWidget {
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('Switch Sample')),
|
||||
body: const Center(
|
||||
child: SwitchExample(),
|
||||
),
|
||||
body: const Center(child: SwitchExample()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,7 @@ class SwitchApp extends StatelessWidget {
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('Switch Sample')),
|
||||
body: const Center(
|
||||
child: SwitchExample(),
|
||||
),
|
||||
body: const Center(child: SwitchExample()),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -40,9 +38,7 @@ class _SwitchExampleState extends State<SwitchExample> {
|
||||
// This object sets amber as the track color when the switch is selected.
|
||||
// Otherwise, it resolves to null and defers to values from the theme data.
|
||||
const WidgetStateProperty<Color?> trackColor = WidgetStateProperty<Color?>.fromMap(
|
||||
<WidgetStatesConstraint, Color>{
|
||||
WidgetState.selected: Colors.amber,
|
||||
},
|
||||
<WidgetStatesConstraint, Color>{WidgetState.selected: Colors.amber},
|
||||
);
|
||||
// This object sets the track color based on two WidgetState attributes.
|
||||
// If neither state applies, it resolves to null.
|
||||
|
||||
@@ -17,9 +17,7 @@ class SwitchApp extends StatelessWidget {
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('Switch Sample')),
|
||||
body: const Center(
|
||||
child: SwitchExample(),
|
||||
),
|
||||
body: const Center(child: SwitchExample()),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -39,7 +37,7 @@ class _SwitchExampleState extends State<SwitchExample> {
|
||||
static const WidgetStateProperty<Icon> thumbIcon = WidgetStateProperty<Icon>.fromMap(
|
||||
<WidgetStatesConstraint, Icon>{
|
||||
WidgetState.selected: Icon(Icons.check),
|
||||
WidgetState.any: Icon(Icons.close),
|
||||
WidgetState.any: Icon(Icons.close),
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -22,9 +22,7 @@ class SwitchApp extends StatelessWidget {
|
||||
),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('Switch Sample')),
|
||||
body: const Center(
|
||||
child: SwitchExample(),
|
||||
),
|
||||
body: const Center(child: SwitchExample()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,13 +23,9 @@ class _SwitchAppState extends State<SwitchApp> {
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = ThemeData(
|
||||
platform: isMaterial ? TargetPlatform.android : TargetPlatform.iOS,
|
||||
adaptations: <Adaptation<Object>>[
|
||||
if (isCustomized) const _SwitchThemeAdaptation()
|
||||
]
|
||||
);
|
||||
final ButtonStyle style = OutlinedButton.styleFrom(
|
||||
fixedSize: const Size(220, 40),
|
||||
adaptations: <Adaptation<Object>>[if (isCustomized) const _SwitchThemeAdaptation()],
|
||||
);
|
||||
final ButtonStyle style = OutlinedButton.styleFrom(fixedSize: const Size(220, 40));
|
||||
|
||||
return MaterialApp(
|
||||
theme: theme,
|
||||
@@ -45,7 +41,10 @@ class _SwitchAppState extends State<SwitchApp> {
|
||||
isMaterial = !isMaterial;
|
||||
});
|
||||
},
|
||||
child: isMaterial ? const Text('Show cupertino style') : const Text('Show material style'),
|
||||
child:
|
||||
isMaterial
|
||||
? const Text('Show cupertino style')
|
||||
: const Text('Show material style'),
|
||||
),
|
||||
OutlinedButton(
|
||||
style: style,
|
||||
@@ -54,7 +53,10 @@ class _SwitchAppState extends State<SwitchApp> {
|
||||
isCustomized = !isCustomized;
|
||||
});
|
||||
},
|
||||
child: isCustomized ? const Text('Remove customization') : const Text('Add customization'),
|
||||
child:
|
||||
isCustomized
|
||||
? const Text('Remove customization')
|
||||
: const Text('Add customization'),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const SwitchWithLabel(label: 'enabled', enabled: true),
|
||||
@@ -67,11 +69,7 @@ class _SwitchAppState extends State<SwitchApp> {
|
||||
}
|
||||
|
||||
class SwitchWithLabel extends StatefulWidget {
|
||||
const SwitchWithLabel({
|
||||
super.key,
|
||||
required this.enabled,
|
||||
required this.label,
|
||||
});
|
||||
const SwitchWithLabel({super.key, required this.enabled, required this.label});
|
||||
|
||||
final bool enabled;
|
||||
final String label;
|
||||
@@ -88,25 +86,23 @@ class _SwitchWithLabelState extends State<SwitchWithLabel> {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 150,
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
child: Text(widget.label)
|
||||
),
|
||||
Container(width: 150, padding: const EdgeInsets.only(right: 20), child: Text(widget.label)),
|
||||
Switch.adaptive(
|
||||
value: active,
|
||||
onChanged: !widget.enabled ? null : (bool value) {
|
||||
setState(() {
|
||||
active = value;
|
||||
});
|
||||
},
|
||||
onChanged:
|
||||
!widget.enabled
|
||||
? null
|
||||
: (bool value) {
|
||||
setState(() {
|
||||
active = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class _SwitchThemeAdaptation extends Adaptation<SwitchThemeData> {
|
||||
const _SwitchThemeAdaptation();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user