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:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -11,18 +11,16 @@ void main() {
}
class IsScrollingListenerApp extends StatelessWidget {
const IsScrollingListenerApp({ super.key });
const IsScrollingListenerApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: IsScrollingListenerExample(),
);
return const MaterialApp(home: IsScrollingListenerExample());
}
}
class IsScrollingListenerExample extends StatefulWidget {
const IsScrollingListenerExample({ super.key });
const IsScrollingListenerExample({super.key});
@override
State<IsScrollingListenerExample> createState() => _IsScrollingListenerExampleState();
@@ -72,7 +70,10 @@ class _IsScrollingListenerExampleState extends State<IsScrollingListenerExample>
} else {
// scroll-end
final ScrollPosition p = scrollController.position;
final int lastIndex = ((p.extentBefore + p.extentInside) ~/ itemExtent).clamp(0, itemCount - 1);
final int lastIndex = ((p.extentBefore + p.extentInside) ~/ itemExtent).clamp(
0,
itemCount - 1,
);
final double alignedScrollOffset = itemExtent * (lastIndex + 1) - p.extentInside;
final double scrollOffset = scrollController.position.pixels;
if (scrollOffset > 0 && (scrollOffset - lastScrollOffset).abs() > itemExtent) {
@@ -101,15 +102,12 @@ class _IsScrollingListenerExampleState extends State<IsScrollingListenerExample>
slivers: <Widget>[
SliverFixedExtentList(
itemExtent: itemExtent,
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return Item(
title: 'Item $index',
color: Color.lerp(Colors.red, Colors.blue, index / itemCount)!
);
},
childCount: itemCount,
),
delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
return Item(
title: 'Item $index',
color: Color.lerp(Colors.red, Colors.blue, index / itemCount)!,
);
}, childCount: itemCount),
),
],
),
@@ -121,19 +119,13 @@ class _IsScrollingListenerExampleState extends State<IsScrollingListenerExample>
}
class Item extends StatelessWidget {
const Item({ super.key, required this.title, required this.color });
const Item({super.key, required this.title, required this.color});
final String title;
final Color color;
@override
Widget build(BuildContext context) {
return Card(
color: color,
child: ListTile(
textColor: Colors.white,
title: Text(title),
),
);
return Card(color: color, child: ListTile(textColor: Colors.white, title: Text(title)));
}
}

View File

@@ -67,20 +67,13 @@ class _ScrollNotificationDemoState extends State<ScrollNotificationDemo> {
slivers: <Widget>[
SliverList.separated(
itemCount: 50,
itemBuilder: (_,int index) {
itemBuilder: (_, int index) {
return Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0,
horizontal: 20.0,
),
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 20.0),
child: Text('Item $index'),
);
},
separatorBuilder: (_, __) => const Divider(
indent: 20,
endIndent: 20,
thickness: 2,
),
separatorBuilder: (_, __) => const Divider(indent: 20, endIndent: 20, thickness: 2),
),
],
);

View File

@@ -21,7 +21,7 @@ class _ScrollControllerDemoState extends State<ScrollControllerDemo> {
void _handleScrollChange() {
if (isScrolling != _controller.position.isScrollingNotifier.value) {
setState((){
setState(() {
isScrolling = _controller.position.isScrollingNotifier.value;
});
}
@@ -59,9 +59,10 @@ class _ScrollControllerDemoState extends State<ScrollControllerDemo> {
home: Scaffold(
appBar: AppBar(
title: Text(isScrolling ? 'Scrolling' : 'Not Scrolling'),
backgroundColor: isScrolling
? Colors.green[800]!.withOpacity(.85)
: Colors.redAccent[700]!.withOpacity(.85),
backgroundColor:
isScrolling
? Colors.green[800]!.withOpacity(.85)
: Colors.redAccent[700]!.withOpacity(.85),
),
// ListView.builder works very similarly to this example with
// CustomScrollView & SliverList.
@@ -79,19 +80,12 @@ class _ScrollControllerDemoState extends State<ScrollControllerDemo> {
decoration: BoxDecoration(
color: Colors.blueGrey[50],
boxShadow: const <BoxShadow>[
BoxShadow(
color: Colors.black12,
offset: Offset(5, 5),
blurRadius: 5,
),
BoxShadow(color: Colors.black12, offset: Offset(5, 5), blurRadius: 5),
],
borderRadius: const BorderRadius.all(Radius.circular(10))
borderRadius: const BorderRadius.all(Radius.circular(10)),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 12.0,
horizontal: 20.0,
),
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 20.0),
child: Text('Item $index'),
),
),

View File

@@ -22,22 +22,19 @@ class ScrollMetricsDemoState extends State<ScrollMetricsDemo> {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('ScrollMetrics Demo'),
),
appBar: AppBar(title: const Text('ScrollMetrics Demo')),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.add),
onPressed: () => setState(() {
windowSize += 10.0;
}),
onPressed:
() => setState(() {
windowSize += 10.0;
}),
),
body: NotificationListener<ScrollMetricsNotification>(
onNotification: (ScrollMetricsNotification notification) {
ScaffoldMessenger.of(notification.context).showSnackBar(
const SnackBar(
content: Text('Scroll metrics changed!'),
),
);
ScaffoldMessenger.of(
notification.context,
).showSnackBar(const SnackBar(content: Text('Scroll metrics changed!')));
return false;
},
child: Scrollbar(
@@ -45,12 +42,7 @@ class ScrollMetricsDemoState extends State<ScrollMetricsDemo> {
child: SizedBox(
height: windowSize,
width: double.infinity,
child: const SingleChildScrollView(
primary: true,
child: FlutterLogo(
size: 300.0,
),
),
child: const SingleChildScrollView(primary: true, child: FlutterLogo(size: 300.0)),
),
),
),