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
@@ -35,15 +35,13 @@ enum ColorLabel {
|
||||
value: color,
|
||||
label: color.label,
|
||||
enabled: color.label != 'Grey',
|
||||
style: MenuItemButton.styleFrom(
|
||||
foregroundColor: color.color,
|
||||
),
|
||||
style: MenuItemButton.styleFrom(foregroundColor: color.color),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
typedef IconEntry = DropdownMenuEntry<IconLabel>;
|
||||
typedef IconEntry = DropdownMenuEntry<IconLabel>;
|
||||
|
||||
// DropdownMenuEntry labels and values for the second dropdown menu.
|
||||
enum IconLabel {
|
||||
@@ -58,11 +56,7 @@ enum IconLabel {
|
||||
|
||||
static final List<IconEntry> entries = UnmodifiableListView<IconEntry>(
|
||||
values.map<IconEntry>(
|
||||
(IconLabel icon) => IconEntry(
|
||||
value: icon,
|
||||
label: icon.label,
|
||||
leadingIcon: Icon(icon.icon),
|
||||
),
|
||||
(IconLabel icon) => IconEntry(value: icon, label: icon.label, leadingIcon: Icon(icon.icon)),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -83,10 +77,7 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
colorSchemeSeed: Colors.green,
|
||||
),
|
||||
theme: ThemeData(useMaterial3: true, colorSchemeSeed: Colors.green),
|
||||
home: Scaffold(
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
@@ -140,15 +131,12 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
|
||||
Text('You selected a ${selectedColor?.label} ${selectedIcon?.label}'),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||
child: Icon(
|
||||
selectedIcon?.icon,
|
||||
color: selectedColor?.color,
|
||||
),
|
||||
)
|
||||
child: Icon(selectedIcon?.icon, color: selectedColor?.color),
|
||||
),
|
||||
],
|
||||
)
|
||||
else
|
||||
const Text('Please select a color and an icon.')
|
||||
const Text('Please select a color and an icon.'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -17,12 +17,10 @@ class DropdownMenuApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3:true),
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('DropdownMenu Sample')),
|
||||
body: const Center(
|
||||
child: DropdownMenuExample(),
|
||||
),
|
||||
body: const Center(child: DropdownMenuExample()),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -35,7 +33,7 @@ class DropdownMenuExample extends StatefulWidget {
|
||||
State<DropdownMenuExample> createState() => _DropdownMenuExampleState();
|
||||
}
|
||||
|
||||
typedef MenuEntry = DropdownMenuEntry<String>;
|
||||
typedef MenuEntry = DropdownMenuEntry<String>;
|
||||
|
||||
class _DropdownMenuExampleState extends State<DropdownMenuExample> {
|
||||
static final List<MenuEntry> menuEntries = UnmodifiableListView<MenuEntry>(
|
||||
|
||||
@@ -19,9 +19,7 @@ class DropdownMenuApp extends StatelessWidget {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('DropdownMenu Sample')),
|
||||
body: const Center(
|
||||
child: DropdownMenuExample(),
|
||||
),
|
||||
body: const Center(child: DropdownMenuExample()),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -52,10 +50,7 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
|
||||
tileColor: colorScheme.primaryContainer,
|
||||
title: const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text('enabled: true'),
|
||||
Text('requestFocusOnTap: true'),
|
||||
],
|
||||
children: <Widget>[Text('enabled: true'), Text('requestFocusOnTap: true')],
|
||||
),
|
||||
subtitle: Column(
|
||||
children: <Widget>[
|
||||
@@ -79,10 +74,7 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
|
||||
tileColor: colorScheme.primaryContainer,
|
||||
title: const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text('enabled: true'),
|
||||
Text('requestFocusOnTap: false'),
|
||||
],
|
||||
children: <Widget>[Text('enabled: true'), Text('requestFocusOnTap: false')],
|
||||
),
|
||||
subtitle: Column(
|
||||
children: <Widget>[
|
||||
@@ -106,10 +98,7 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
|
||||
tileColor: colorScheme.onInverseSurface,
|
||||
title: const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text('enabled: false'),
|
||||
Text('requestFocusOnTap: true'),
|
||||
],
|
||||
children: <Widget>[Text('enabled: false'), Text('requestFocusOnTap: true')],
|
||||
),
|
||||
subtitle: Column(
|
||||
children: <Widget>[
|
||||
@@ -134,10 +123,7 @@ class _DropdownMenuExampleState extends State<DropdownMenuExample> {
|
||||
tileColor: colorScheme.onInverseSurface,
|
||||
title: const Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text('enabled: false'),
|
||||
Text('requestFocusOnTap: false'),
|
||||
],
|
||||
children: <Widget>[Text('enabled: false'), Text('requestFocusOnTap: false')],
|
||||
),
|
||||
subtitle: Column(
|
||||
children: <Widget>[
|
||||
|
||||
@@ -19,10 +19,11 @@ enum ColorItem {
|
||||
}
|
||||
|
||||
class DropdownMenuEntryLabelWidgetExample extends StatefulWidget {
|
||||
const DropdownMenuEntryLabelWidgetExample({ super.key });
|
||||
const DropdownMenuEntryLabelWidgetExample({super.key});
|
||||
|
||||
@override
|
||||
State<DropdownMenuEntryLabelWidgetExample> createState() => _DropdownMenuEntryLabelWidgetExampleState();
|
||||
State<DropdownMenuEntryLabelWidgetExample> createState() =>
|
||||
_DropdownMenuEntryLabelWidgetExampleState();
|
||||
}
|
||||
|
||||
class _DropdownMenuEntryLabelWidgetExampleState extends State<DropdownMenuEntryLabelWidgetExample> {
|
||||
@@ -43,7 +44,8 @@ class _DropdownMenuEntryLabelWidgetExampleState extends State<DropdownMenuEntryL
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Created by Google Bard from 'create a lyrical phrase of about 25 words that begins with "is a color"'.
|
||||
const String longText = 'is a color that sings of hope, A hue that shines like gold. It is the color of dreams, A shade that never grows old.';
|
||||
const String longText =
|
||||
'is a color that sings of hope, A hue that shines like gold. It is the color of dreams, A shade that never grows old.';
|
||||
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
@@ -55,20 +57,17 @@ class _DropdownMenuEntryLabelWidgetExampleState extends State<DropdownMenuEntryL
|
||||
onSelected: (ColorItem? color) {
|
||||
print('Selected $color');
|
||||
},
|
||||
dropdownMenuEntries: ColorItem.values.map<DropdownMenuEntry<ColorItem>>((ColorItem item) {
|
||||
final String labelText = '${item.label} $longText\n';
|
||||
return DropdownMenuEntry<ColorItem>(
|
||||
value: item,
|
||||
label: labelText,
|
||||
// Try commenting the labelWidget out or changing
|
||||
// the labelWidget's Text parameters.
|
||||
labelWidget: Text(
|
||||
labelText,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
dropdownMenuEntries:
|
||||
ColorItem.values.map<DropdownMenuEntry<ColorItem>>((ColorItem item) {
|
||||
final String labelText = '${item.label} $longText\n';
|
||||
return DropdownMenuEntry<ColorItem>(
|
||||
value: item,
|
||||
label: labelText,
|
||||
// Try commenting the labelWidget out or changing
|
||||
// the labelWidget's Text parameters.
|
||||
labelWidget: Text(labelText, maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -76,13 +75,11 @@ class _DropdownMenuEntryLabelWidgetExampleState extends State<DropdownMenuEntryL
|
||||
}
|
||||
|
||||
class DropdownMenuEntryLabelWidgetExampleApp extends StatelessWidget {
|
||||
const DropdownMenuEntryLabelWidgetExampleApp({ super.key });
|
||||
const DropdownMenuEntryLabelWidgetExampleApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
home: DropdownMenuEntryLabelWidgetExample(),
|
||||
);
|
||||
return const MaterialApp(home: DropdownMenuEntryLabelWidgetExample());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user