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

@@ -8,9 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Appbar updates on navigation', (WidgetTester tester) async {
await tester.pumpWidget(
const example.AppBarApp(),
);
await tester.pumpWidget(const example.AppBarApp());
expect(find.widgetWithText(AppBar, 'AppBar Demo'), findsOneWidget);
expect(find.text('This is the home page'), findsOneWidget);

View File

@@ -10,9 +10,7 @@ const Offset _kOffset = Offset(0.0, -100.0);
void main() {
testWidgets('Appbar Material 3 test', (WidgetTester tester) async {
await tester.pumpWidget(
const example.AppBarApp()
);
await tester.pumpWidget(const example.AppBarApp());
expect(find.widgetWithText(AppBar, 'AppBar Demo'), findsOneWidget);
Material appbarMaterial = _getAppBarMaterial(tester);
@@ -47,9 +45,6 @@ void main() {
Material _getAppBarMaterial(WidgetTester tester) {
return tester.widget<Material>(
find.descendant(
of: find.byType(AppBar),
matching: find.byType(Material),
),
find.descendant(of: find.byType(AppBar), matching: find.byType(Material)),
);
}

View File

@@ -8,9 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Appbar and actions', (WidgetTester tester) async {
await tester.pumpWidget(
const example.AppBarApp(),
);
await tester.pumpWidget(const example.AppBarApp());
expect(find.byType(AppBar), findsOneWidget);
expect(find.widgetWithText(TextButton, 'Action 1'), findsOneWidget);

View File

@@ -7,25 +7,22 @@ import 'package:flutter_api_samples/material/app_bar/app_bar.3.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'AppBar elevates when nested scroll view is scrolled underneath the AppBar',
(WidgetTester tester) async {
Material getMaterial() => tester.widget<Material>(find.descendant(
of: find.byType(AppBar),
matching: find.byType(Material),
));
testWidgets('AppBar elevates when nested scroll view is scrolled underneath the AppBar', (
WidgetTester tester,
) async {
Material getMaterial() => tester.widget<Material>(
find.descendant(of: find.byType(AppBar), matching: find.byType(Material)),
);
await tester.pumpWidget(
const example.AppBarApp(),
);
await tester.pumpWidget(const example.AppBarApp());
// Starts with the base elevation.
expect(getMaterial().elevation, 0.0);
// Starts with the base elevation.
expect(getMaterial().elevation, 0.0);
await tester.fling(find.text('Beach 3'), const Offset(0.0, -600.0), 2000.0);
await tester.pumpAndSettle();
await tester.fling(find.text('Beach 3'), const Offset(0.0, -600.0), 2000.0);
await tester.pumpAndSettle();
// After scrolling it should be the scrolledUnderElevation.
expect(getMaterial().elevation, 4.0);
// After scrolling it should be the scrolledUnderElevation.
expect(getMaterial().elevation, 4.0);
});
}

View File

@@ -8,21 +8,16 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('AppBar uses custom shape', (WidgetTester tester) async {
await tester.pumpWidget(
const example.AppBarExampleApp(),
);
await tester.pumpWidget(const example.AppBarExampleApp());
Material getMaterial() => tester.widget<Material>(find.descendant(
of: find.byType(AppBar),
matching: find.byType(Material),
));
Material getMaterial() => tester.widget<Material>(
find.descendant(of: find.byType(AppBar), matching: find.byType(Material)),
);
expect(getMaterial().shape, const example.CustomAppBarShape());
});
testWidgets('AppBar bottom contains TextField', (WidgetTester tester) async {
await tester.pumpWidget(
const example.AppBarExampleApp(),
);
await tester.pumpWidget(const example.AppBarExampleApp());
final Finder textFieldFinder = find.descendant(
of: find.byType(AppBar),

View File

@@ -10,9 +10,7 @@ const Offset _kOffset = Offset(0.0, -200.0);
void main() {
testWidgets('SliverAppbar can be pinned', (WidgetTester tester) async {
await tester.pumpWidget(
const example.AppBarApp(),
);
await tester.pumpWidget(const example.AppBarApp());
expect(find.widgetWithText(SliverAppBar, 'SliverAppBar'), findsOneWidget);
expect(tester.getBottomLeft(find.text('SliverAppBar')).dy, 144.0);

View File

@@ -12,15 +12,18 @@ void main() {
const String title = 'Medium App Bar';
expect(find.descendant(
of: find.byType(CustomScrollView),
matching: find.widgetWithText(SliverAppBar, title),
), findsOne);
expect(
find.descendant(
of: find.byType(CustomScrollView),
matching: find.widgetWithText(SliverAppBar, title),
),
findsOne,
);
expect(find.descendant(
of: find.byType(SliverAppBar),
matching: find.byType(IconButton),
), findsExactly(2));
expect(
find.descendant(of: find.byType(SliverAppBar), matching: find.byType(IconButton)),
findsExactly(2),
);
// Based on https://m3.material.io/components/top-app-bar/specs the title of
// the SliverAppBar.medium widget is formatted with the headlineSmall style.

View File

@@ -12,15 +12,18 @@ void main() {
const String title = 'Large App Bar';
expect(find.descendant(
of: find.byType(CustomScrollView),
matching: find.widgetWithText(SliverAppBar, title),
), findsOne);
expect(
find.descendant(
of: find.byType(CustomScrollView),
matching: find.widgetWithText(SliverAppBar, title),
),
findsOne,
);
expect(find.descendant(
of: find.byType(SliverAppBar),
matching: find.byType(IconButton),
), findsExactly(2));
expect(
find.descendant(of: find.byType(SliverAppBar), matching: find.byType(IconButton)),
findsExactly(2),
);
// Based on https://m3.material.io/components/top-app-bar/specs the title of
// the SliverAppBar.large widget is formatted with the headlineMedium style.

View File

@@ -3,17 +3,14 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/material/app_bar/sliver_app_bar.4.dart'
as example;
import 'package:flutter_api_samples/material/app_bar/sliver_app_bar.4.dart' as example;
import 'package:flutter_test/flutter_test.dart';
const Offset _kOffset = Offset(0.0, 200.0);
void main() {
testWidgets('SliverAppbar can be stretched', (WidgetTester tester) async {
await tester.pumpWidget(
const example.StretchableSliverAppBar(),
);
await tester.pumpWidget(const example.StretchableSliverAppBar());
final Finder switchFinder = find.byType(Switch);
Switch materialSwitch = tester.widget<Switch>(switchFinder);
@@ -22,21 +19,18 @@ void main() {
expect(find.widgetWithText(SliverAppBar, 'SliverAppBar'), findsOneWidget);
expect(tester.getBottomLeft(find.text('SliverAppBar')).dy, 184.0);
await tester.drag(find.text('0'), _kOffset,
touchSlopY: 0, warnIfMissed: false);
await tester.drag(find.text('0'), _kOffset, touchSlopY: 0, warnIfMissed: false);
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(find.widgetWithText(SliverAppBar, 'SliverAppBar'), findsOneWidget);
expect(
tester.getBottomLeft(find.text('SliverAppBar')).dy, 187.63506380825314);
expect(tester.getBottomLeft(find.text('SliverAppBar')).dy, 187.63506380825314);
await tester.tap(switchFinder);
await tester.pumpAndSettle();
materialSwitch = tester.widget<Switch>(switchFinder);
expect(materialSwitch.value, false);
await tester.drag(find.text('0'), _kOffset,
touchSlopY: 0, warnIfMissed: false);
await tester.drag(find.text('0'), _kOffset, touchSlopY: 0, warnIfMissed: false);
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));