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

@@ -3,38 +3,32 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.0.dart'
as example;
import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'GestureDetector updates icon color and text on tap',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.GestureDetectorExampleApp(),
);
testWidgets('GestureDetector updates icon color and text on tap', (WidgetTester tester) async {
await tester.pumpWidget(const example.GestureDetectorExampleApp());
Icon icon = tester.widget(find.byIcon(Icons.lightbulb_outline));
Icon icon = tester.widget(find.byIcon(Icons.lightbulb_outline));
expect(find.text('TURN LIGHT ON'), findsOneWidget);
expect(icon.color, Colors.black);
expect(find.text('TURN LIGHT ON'), findsOneWidget);
expect(icon.color, Colors.black);
await tester.tap(find.byType(GestureDetector));
await tester.pump();
await tester.tap(find.byType(GestureDetector));
await tester.pump();
icon = tester.widget(find.byIcon(Icons.lightbulb_outline));
icon = tester.widget(find.byIcon(Icons.lightbulb_outline));
expect(find.text('TURN LIGHT OFF'), findsOneWidget);
expect(icon.color, Colors.yellow.shade600);
expect(find.text('TURN LIGHT OFF'), findsOneWidget);
expect(icon.color, Colors.yellow.shade600);
await tester.tap(find.byType(GestureDetector));
await tester.pump();
await tester.tap(find.byType(GestureDetector));
await tester.pump();
icon = tester.widget(find.byIcon(Icons.lightbulb_outline));
icon = tester.widget(find.byIcon(Icons.lightbulb_outline));
expect(find.text('TURN LIGHT ON'), findsOneWidget);
expect(icon.color, Colors.black);
},
);
expect(find.text('TURN LIGHT ON'), findsOneWidget);
expect(icon.color, Colors.black);
});
}

View File

@@ -3,50 +3,35 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.1.dart'
as example;
import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'GestureDetector updates Container color on tap',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.GestureDetectorExampleApp(),
);
testWidgets('GestureDetector updates Container color on tap', (WidgetTester tester) async {
await tester.pumpWidget(const example.GestureDetectorExampleApp());
Container container = tester.widget(
find.ancestor(
of: find.byType(GestureDetector),
matching: find.byType(Container),
),
);
Container container = tester.widget(
find.ancestor(of: find.byType(GestureDetector), matching: find.byType(Container)),
);
expect(container.color, Colors.white);
expect(container.color, Colors.white);
await tester.tap(find.byType(GestureDetector));
await tester.pump();
await tester.tap(find.byType(GestureDetector));
await tester.pump();
container = tester.widget(
find.ancestor(
of: find.byType(GestureDetector),
matching: find.byType(Container),
),
);
container = tester.widget(
find.ancestor(of: find.byType(GestureDetector), matching: find.byType(Container)),
);
expect(container.color, Colors.yellow);
expect(container.color, Colors.yellow);
await tester.tap(find.byType(GestureDetector));
await tester.pump();
await tester.tap(find.byType(GestureDetector));
await tester.pump();
container = tester.widget(
find.ancestor(
of: find.byType(GestureDetector),
matching: find.byType(Container),
),
);
container = tester.widget(
find.ancestor(of: find.byType(GestureDetector), matching: find.byType(Container)),
);
expect(container.color, Colors.white);
},
);
expect(container.color, Colors.white);
});
}

View File

@@ -3,12 +3,10 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.2.dart'
as example;
import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.2.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
void expectBorders(
WidgetTester tester, {
required bool expectGreenHasBorder,
@@ -30,14 +28,16 @@ void main() {
void expectInnerGestureDetectorBehavior(WidgetTester tester, HitTestBehavior behavior) {
// There is a third GestureDetector added by Scaffold.
final Finder innerGestureDetectorFinder = find.byType(GestureDetector).at(1);
final GestureDetector innerGestureDetector = tester.firstWidget<GestureDetector>(innerGestureDetectorFinder);
final GestureDetector innerGestureDetector = tester.firstWidget<GestureDetector>(
innerGestureDetectorFinder,
);
expect(innerGestureDetector.behavior, behavior);
}
testWidgets('Only the green Container shows a red border when tapped', (WidgetTester tester) async {
await tester.pumpWidget(
const example.NestedGestureDetectorsApp(),
);
testWidgets('Only the green Container shows a red border when tapped', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.NestedGestureDetectorsApp());
final Finder greenFinder = find.byType(Container).first;
final Offset greenTopLeftCorner = tester.getTopLeft(greenFinder);
@@ -63,10 +63,10 @@ void main() {
expectInnerGestureDetectorBehavior(tester, HitTestBehavior.opaque);
});
testWidgets('Only the yellow Container shows a red border when tapped', (WidgetTester tester) async {
await tester.pumpWidget(
const example.NestedGestureDetectorsApp(),
);
testWidgets('Only the yellow Container shows a red border when tapped', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.NestedGestureDetectorsApp());
final Finder yellowFinder = find.byType(Container).last;
final Offset yellowTopLeftCorner = tester.getTopLeft(yellowFinder);

View File

@@ -4,15 +4,12 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.3.dart'
as example;
import 'package:flutter_api_samples/widgets/gesture_detector/gesture_detector.3.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('The red box always moves inside the green box', (WidgetTester tester) async {
await tester.pumpWidget(
const example.DragBoundaryExampleApp(),
);
await tester.pumpWidget(const example.DragBoundaryExampleApp());
final Finder greenFinder = find.byType(Container).first;
final Finder redFinder = find.byType(Container).last;
final TestGesture drag = await tester.startGesture(tester.getCenter(redFinder));