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
@@ -53,17 +53,13 @@ class _ContextMenuControllerExampleAppState extends State<ContextMenuControllerE
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Context menu outside of text'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Context menu outside of text')),
|
||||
body: _ContextMenuRegion(
|
||||
contextMenuBuilder: (BuildContext context, Offset offset) {
|
||||
// The custom context menu will look like the default context menu
|
||||
// on the current platform with a single 'Print' button.
|
||||
return AdaptiveTextSelectionToolbar.buttonItems(
|
||||
anchors: TextSelectionToolbarAnchors(
|
||||
primaryAnchor: offset,
|
||||
),
|
||||
anchors: TextSelectionToolbarAnchors(primaryAnchor: offset),
|
||||
buttonItems: <ContextMenuButtonItem>[
|
||||
ContextMenuButtonItem(
|
||||
onPressed: () {
|
||||
@@ -82,7 +78,8 @@ class _ContextMenuControllerExampleAppState extends State<ContextMenuControllerE
|
||||
children: <Widget>[
|
||||
Container(height: 20.0),
|
||||
const Text(
|
||||
'Right click (desktop) or long press (mobile) anywhere, not just on this text, to show the custom menu.'),
|
||||
'Right click (desktop) or long press (mobile) anywhere, not just on this text, to show the custom menu.',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -96,10 +93,7 @@ class _ContextMenuControllerExampleAppState extends State<ContextMenuControllerE
|
||||
/// By default, shows the menu on right clicks and long presses.
|
||||
class _ContextMenuRegion extends StatefulWidget {
|
||||
/// Creates an instance of [_ContextMenuRegion].
|
||||
const _ContextMenuRegion({
|
||||
required this.child,
|
||||
required this.contextMenuBuilder,
|
||||
});
|
||||
const _ContextMenuRegion({required this.child, required this.contextMenuBuilder});
|
||||
|
||||
/// Builds the context menu.
|
||||
final ContextMenuBuilder contextMenuBuilder;
|
||||
|
||||
@@ -16,10 +16,12 @@ class EditableTextToolbarBuilderExampleApp extends StatefulWidget {
|
||||
const EditableTextToolbarBuilderExampleApp({super.key});
|
||||
|
||||
@override
|
||||
State<EditableTextToolbarBuilderExampleApp> createState() => _EditableTextToolbarBuilderExampleAppState();
|
||||
State<EditableTextToolbarBuilderExampleApp> createState() =>
|
||||
_EditableTextToolbarBuilderExampleAppState();
|
||||
}
|
||||
|
||||
class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolbarBuilderExampleApp> {
|
||||
class _EditableTextToolbarBuilderExampleAppState
|
||||
extends State<EditableTextToolbarBuilderExampleApp> {
|
||||
final TextEditingController _controller = TextEditingController(
|
||||
text: 'Right click (desktop) or long press (mobile) to see the menu with custom buttons.',
|
||||
);
|
||||
@@ -46,9 +48,7 @@ class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolb
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Custom button appearance'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Custom button appearance')),
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
@@ -61,21 +61,27 @@ class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolb
|
||||
// Build the default buttons, but make them look custom.
|
||||
// In a real project you may want to build different
|
||||
// buttons depending on the platform.
|
||||
children: editableTextState.contextMenuButtonItems.map((ContextMenuButtonItem buttonItem) {
|
||||
return CupertinoButton(
|
||||
color: const Color(0xffaaaa00),
|
||||
disabledColor: const Color(0xffaaaaff),
|
||||
onPressed: buttonItem.onPressed,
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
pressedOpacity: 0.7,
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
child: Text(
|
||||
CupertinoTextSelectionToolbarButton.getButtonLabel(context, buttonItem),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
children:
|
||||
editableTextState.contextMenuButtonItems.map((
|
||||
ContextMenuButtonItem buttonItem,
|
||||
) {
|
||||
return CupertinoButton(
|
||||
color: const Color(0xffaaaa00),
|
||||
disabledColor: const Color(0xffaaaaff),
|
||||
onPressed: buttonItem.onPressed,
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
pressedOpacity: 0.7,
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
child: Text(
|
||||
CupertinoTextSelectionToolbarButton.getButtonLabel(
|
||||
context,
|
||||
buttonItem,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -18,19 +18,20 @@ class EditableTextToolbarBuilderExampleApp extends StatefulWidget {
|
||||
const EditableTextToolbarBuilderExampleApp({super.key});
|
||||
|
||||
@override
|
||||
State<EditableTextToolbarBuilderExampleApp> createState() => _EditableTextToolbarBuilderExampleAppState();
|
||||
State<EditableTextToolbarBuilderExampleApp> createState() =>
|
||||
_EditableTextToolbarBuilderExampleAppState();
|
||||
}
|
||||
|
||||
class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolbarBuilderExampleApp> {
|
||||
final TextEditingController _controller = TextEditingController(
|
||||
text: text,
|
||||
);
|
||||
class _EditableTextToolbarBuilderExampleAppState
|
||||
extends State<EditableTextToolbarBuilderExampleApp> {
|
||||
final TextEditingController _controller = TextEditingController(text: text);
|
||||
|
||||
void _showDialog(BuildContext context) {
|
||||
Navigator.of(context).push(
|
||||
DialogRoute<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => const AlertDialog(title: Text('You clicked send email!')),
|
||||
builder:
|
||||
(BuildContext context) => const AlertDialog(title: Text('You clicked send email!')),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -57,9 +58,7 @@ class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolb
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Custom button for emails'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Custom button for emails')),
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
@@ -67,7 +66,8 @@ class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolb
|
||||
TextField(
|
||||
controller: _controller,
|
||||
contextMenuBuilder: (BuildContext context, EditableTextState editableTextState) {
|
||||
final List<ContextMenuButtonItem> buttonItems = editableTextState.contextMenuButtonItems;
|
||||
final List<ContextMenuButtonItem> buttonItems =
|
||||
editableTextState.contextMenuButtonItems;
|
||||
// Here we add an "Email" button to the default TextField
|
||||
// context menu for the current platform, but only if an email
|
||||
// address is currently selected.
|
||||
|
||||
@@ -15,10 +15,12 @@ class EditableTextToolbarBuilderExampleApp extends StatefulWidget {
|
||||
const EditableTextToolbarBuilderExampleApp({super.key});
|
||||
|
||||
@override
|
||||
State<EditableTextToolbarBuilderExampleApp> createState() => _EditableTextToolbarBuilderExampleAppState();
|
||||
State<EditableTextToolbarBuilderExampleApp> createState() =>
|
||||
_EditableTextToolbarBuilderExampleAppState();
|
||||
}
|
||||
|
||||
class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolbarBuilderExampleApp> {
|
||||
class _EditableTextToolbarBuilderExampleAppState
|
||||
extends State<EditableTextToolbarBuilderExampleApp> {
|
||||
final TextEditingController _controller = TextEditingController(
|
||||
text: 'Right click (desktop) or long press (mobile) to see the menu with a custom toolbar.',
|
||||
);
|
||||
@@ -45,9 +47,7 @@ class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolb
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Custom toolbar, default-looking buttons'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Custom toolbar, default-looking buttons')),
|
||||
body: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
@@ -59,32 +59,33 @@ class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolb
|
||||
anchor: editableTextState.contextMenuAnchors.primaryAnchor,
|
||||
// getAdaptiveButtons creates the default button widgets for
|
||||
// the current platform.
|
||||
children: AdaptiveTextSelectionToolbar.getAdaptiveButtons(
|
||||
context,
|
||||
// These buttons just close the menu when clicked.
|
||||
<ContextMenuButtonItem>[
|
||||
ContextMenuButtonItem(
|
||||
label: 'One',
|
||||
onPressed: () => ContextMenuController.removeAny(),
|
||||
),
|
||||
ContextMenuButtonItem(
|
||||
label: 'Two',
|
||||
onPressed: () => ContextMenuController.removeAny(),
|
||||
),
|
||||
ContextMenuButtonItem(
|
||||
label: 'Three',
|
||||
onPressed: () => ContextMenuController.removeAny(),
|
||||
),
|
||||
ContextMenuButtonItem(
|
||||
label: 'Four',
|
||||
onPressed: () => ContextMenuController.removeAny(),
|
||||
),
|
||||
ContextMenuButtonItem(
|
||||
label: 'Five',
|
||||
onPressed: () => ContextMenuController.removeAny(),
|
||||
),
|
||||
],
|
||||
).toList(),
|
||||
children:
|
||||
AdaptiveTextSelectionToolbar.getAdaptiveButtons(
|
||||
context,
|
||||
// These buttons just close the menu when clicked.
|
||||
<ContextMenuButtonItem>[
|
||||
ContextMenuButtonItem(
|
||||
label: 'One',
|
||||
onPressed: () => ContextMenuController.removeAny(),
|
||||
),
|
||||
ContextMenuButtonItem(
|
||||
label: 'Two',
|
||||
onPressed: () => ContextMenuController.removeAny(),
|
||||
),
|
||||
ContextMenuButtonItem(
|
||||
label: 'Three',
|
||||
onPressed: () => ContextMenuController.removeAny(),
|
||||
),
|
||||
ContextMenuButtonItem(
|
||||
label: 'Four',
|
||||
onPressed: () => ContextMenuController.removeAny(),
|
||||
),
|
||||
ContextMenuButtonItem(
|
||||
label: 'Five',
|
||||
onPressed: () => ContextMenuController.removeAny(),
|
||||
),
|
||||
],
|
||||
).toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -100,10 +101,7 @@ class _EditableTextToolbarBuilderExampleAppState extends State<EditableTextToolb
|
||||
///
|
||||
/// Displays its children in a scrollable grid.
|
||||
class _MyTextSelectionToolbar extends StatelessWidget {
|
||||
const _MyTextSelectionToolbar({
|
||||
required this.anchor,
|
||||
required this.children,
|
||||
});
|
||||
const _MyTextSelectionToolbar({required this.anchor, required this.children});
|
||||
|
||||
final Offset anchor;
|
||||
final List<Widget> children;
|
||||
|
||||
@@ -18,10 +18,12 @@ class SelectableRegionToolbarBuilderExampleApp extends StatefulWidget {
|
||||
const SelectableRegionToolbarBuilderExampleApp({super.key});
|
||||
|
||||
@override
|
||||
State<SelectableRegionToolbarBuilderExampleApp> createState() => _SelectableRegionToolbarBuilderExampleAppState();
|
||||
State<SelectableRegionToolbarBuilderExampleApp> createState() =>
|
||||
_SelectableRegionToolbarBuilderExampleAppState();
|
||||
}
|
||||
|
||||
class _SelectableRegionToolbarBuilderExampleAppState extends State<SelectableRegionToolbarBuilderExampleApp> {
|
||||
class _SelectableRegionToolbarBuilderExampleAppState
|
||||
extends State<SelectableRegionToolbarBuilderExampleApp> {
|
||||
void _showDialog(BuildContext context) {
|
||||
Navigator.of(context).push(
|
||||
DialogRoute<void>(
|
||||
@@ -53,9 +55,7 @@ class _SelectableRegionToolbarBuilderExampleAppState extends State<SelectableReg
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Context menu anywhere'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Context menu anywhere')),
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 200.0,
|
||||
@@ -78,12 +78,7 @@ class _SelectableRegionToolbarBuilderExampleAppState extends State<SelectableReg
|
||||
],
|
||||
);
|
||||
},
|
||||
child: ListView(
|
||||
children: const <Widget>[
|
||||
SizedBox(height: 20.0),
|
||||
Text(text),
|
||||
],
|
||||
),
|
||||
child: ListView(children: const <Widget>[SizedBox(height: 20.0), Text(text)]),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user