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
@@ -15,10 +15,7 @@ class FocusExampleApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
appBar: AppBar(title: const Text('Focus Sample')),
|
||||
body: const FocusExample(),
|
||||
),
|
||||
home: Scaffold(appBar: AppBar(title: const Text('Focus Sample')), body: const FocusExample()),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -39,15 +36,21 @@ class _FocusExampleState extends State<FocusExample> {
|
||||
switch (event.logicalKey) {
|
||||
case LogicalKeyboardKey.keyR:
|
||||
debugPrint('Changing color to red.');
|
||||
setState(() { _color = Colors.red; });
|
||||
setState(() {
|
||||
_color = Colors.red;
|
||||
});
|
||||
return KeyEventResult.handled;
|
||||
case LogicalKeyboardKey.keyG:
|
||||
debugPrint('Changing color to green.');
|
||||
setState(() { _color = Colors.green; });
|
||||
setState(() {
|
||||
_color = Colors.green;
|
||||
});
|
||||
return KeyEventResult.handled;
|
||||
case LogicalKeyboardKey.keyB:
|
||||
debugPrint('Changing color to blue.');
|
||||
setState(() { _color = Colors.blue; });
|
||||
setState(() {
|
||||
_color = Colors.blue;
|
||||
});
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,12 @@ class FocusExampleApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
home: FocusExample(),
|
||||
);
|
||||
return const MaterialApp(home: FocusExample());
|
||||
}
|
||||
}
|
||||
|
||||
class FocusableText extends StatelessWidget {
|
||||
const FocusableText(
|
||||
this.data, {
|
||||
super.key,
|
||||
required this.autofocus,
|
||||
});
|
||||
const FocusableText(this.data, {super.key, required this.autofocus});
|
||||
|
||||
/// The string to display as the text for this widget.
|
||||
final String data;
|
||||
@@ -36,21 +30,23 @@ class FocusableText extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Focus(
|
||||
autofocus: autofocus,
|
||||
child: Builder(builder: (BuildContext context) {
|
||||
// The contents of this Builder are being made focusable. It is inside
|
||||
// of a Builder because the builder provides the correct context
|
||||
// variable for Focus.of() to be able to find the Focus widget that is
|
||||
// the Builder's parent. Without the builder, the context variable used
|
||||
// would be the one given the FocusableText build function, and that
|
||||
// would start looking for a Focus widget ancestor of the FocusableText
|
||||
// instead of finding the one inside of its build function.
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
// Change the color based on whether or not this Container has focus.
|
||||
color: Focus.of(context).hasPrimaryFocus ? Colors.red : Colors.white,
|
||||
child: Text(data),
|
||||
);
|
||||
}),
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
// The contents of this Builder are being made focusable. It is inside
|
||||
// of a Builder because the builder provides the correct context
|
||||
// variable for Focus.of() to be able to find the Focus widget that is
|
||||
// the Builder's parent. Without the builder, the context variable used
|
||||
// would be the one given the FocusableText build function, and that
|
||||
// would start looking for a Focus widget ancestor of the FocusableText
|
||||
// instead of finding the one inside of its build function.
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
// Change the color based on whether or not this Container has focus.
|
||||
color: Focus.of(context).hasPrimaryFocus ? Colors.red : Colors.white,
|
||||
child: Text(data),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -62,10 +58,9 @@ class FocusExample extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) => FocusableText(
|
||||
'Item $index',
|
||||
autofocus: index == 0,
|
||||
),
|
||||
itemBuilder:
|
||||
(BuildContext context, int index) =>
|
||||
FocusableText('Item $index', autofocus: index == 0),
|
||||
itemCount: 50,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -13,9 +13,7 @@ class FocusExampleApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
home: FocusExample(),
|
||||
);
|
||||
return const MaterialApp(home: FocusExample());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,24 +49,22 @@ class _FocusExampleState extends State<FocusExample> {
|
||||
// node is not yet part of the focus tree.
|
||||
childFocusNodes.add(FocusNode(debugLabel: 'Child ${children.length}')..requestFocus());
|
||||
|
||||
children.add(Padding(
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
child: ActionChip(
|
||||
focusNode: childFocusNodes.last,
|
||||
label: Text('CHILD ${children.length}'),
|
||||
onPressed: () {},
|
||||
children.add(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
child: ActionChip(
|
||||
focusNode: childFocusNodes.last,
|
||||
label: Text('CHILD ${children.length}'),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Wrap(
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
body: Center(child: Wrap(children: children)),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
|
||||
@@ -13,9 +13,7 @@ class FocusScopeExampleApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const MaterialApp(
|
||||
home: FocusScopeExample(),
|
||||
);
|
||||
return const MaterialApp(home: FocusScopeExample());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,9 +43,7 @@ class Pane extends StatelessWidget {
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: <Widget>[
|
||||
Center(
|
||||
child: child,
|
||||
),
|
||||
Center(child: child),
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: IconButton(
|
||||
|
||||
Reference in New Issue
Block a user