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

@@ -10,20 +10,27 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('AbsorbPointer prevents hit testing on its child', (WidgetTester tester) async {
await tester.pumpWidget(
const example.AbsorbPointerApp(),
);
await tester.pumpWidget(const example.AbsorbPointerApp());
// Get the center of the stack.
final Offset center = tester.getCenter(find.byType(Stack).first);
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse, pointer: 1);
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
pointer: 1,
);
// Add the point to the center of the stack where the AbsorbPointer is.
await gesture.addPointer(location: center);
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.basic,
);
// Move the pointer to the left of the stack where the AbsorbPointer is not.
await gesture.moveTo(center + const Offset(-100, 0));
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.click,
);
});
}

View File

@@ -10,9 +10,7 @@ void main() {
testWidgets('AspectRatio applies 16 / 9 aspect ratio on its child', (WidgetTester tester) async {
const double height = 100.0;
await tester.pumpWidget(
const example.AspectRatioApp(),
);
await tester.pumpWidget(const example.AspectRatioApp());
final Size parentContainer = tester.getSize(find.byType(Container).first);
expect(parentContainer.width, 800.0);

View File

@@ -10,9 +10,7 @@ void main() {
testWidgets('AspectRatio applies 2.0 aspect ratio on its child', (WidgetTester tester) async {
const Size containerSize = Size(100, 100);
await tester.pumpWidget(
const example.AspectRatioApp(),
);
await tester.pumpWidget(const example.AspectRatioApp());
final Size parentContainer = tester.getSize(find.byType(Container).first);
expect(parentContainer, containerSize);

View File

@@ -10,9 +10,7 @@ void main() {
testWidgets('AspectRatio applies 0.5 aspect ratio on its child', (WidgetTester tester) async {
const Size containerSize = Size(100, 100);
await tester.pumpWidget(
const example.AspectRatioApp(),
);
await tester.pumpWidget(const example.AspectRatioApp());
final Size parentContainer = tester.getSize(find.byType(Container).first);
expect(parentContainer, containerSize);

View File

@@ -8,9 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('ClipRRect adds rounded corners to containers', (WidgetTester tester) async {
await tester.pumpWidget(
const example.ClipRRectApp(),
);
await tester.pumpWidget(const example.ClipRRectApp());
final Finder clipRRectFinder = find.byType(ClipRRect);
final Finder containerFinder = find.byType(Container);

View File

@@ -8,9 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('ClipRRect fits to its child', (WidgetTester tester) async {
await tester.pumpWidget(
const example.ClipRRectApp(),
);
await tester.pumpWidget(const example.ClipRRectApp());
final Finder clipRRectFinder = find.byType(ClipRRect);
final Finder logoFinder = find.byType(FlutterLogo);

View File

@@ -3,26 +3,19 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/basic/custom_multi_child_layout.0.dart'
as example;
import 'package:flutter_api_samples/widgets/basic/custom_multi_child_layout.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('has four containers', (WidgetTester tester) async {
await tester.pumpWidget(
const example.CustomMultiChildLayoutApp(),
);
await tester.pumpWidget(const example.CustomMultiChildLayoutApp());
final Finder containerFinder = find.byType(Container);
expect(containerFinder, findsNWidgets(4));
});
testWidgets('containers are the same size', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: example.CustomMultiChildLayoutExample(),
),
),
const MaterialApp(home: Scaffold(body: example.CustomMultiChildLayoutExample())),
);
final Finder containerFinder = find.byType(Container);
const Size expectedSize = Size(100, 100);
@@ -34,11 +27,7 @@ void main() {
testWidgets('containers are offset', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: example.CustomMultiChildLayoutExample(),
),
),
const MaterialApp(home: Scaffold(body: example.CustomMultiChildLayoutExample())),
);
final Finder containerFinder = find.byType(Container);
Rect previousRect = tester.getRect(containerFinder.first);

View File

@@ -16,9 +16,7 @@ void main() {
const double containerTwoHeight = columnHeight - 200;
const double containerThreeHeight = 100;
await tester.pumpWidget(
const example.ExpandedApp(),
);
await tester.pumpWidget(const example.ExpandedApp());
final Size column = tester.getSize(find.byType(Column));
expect(column, const Size(columnWidth, columnHeight));

View File

@@ -14,9 +14,7 @@ void main() {
const double containerTwoWidth = 50;
const double containerThreeWidth = (rowWidth - 50) * 1 / 3;
await tester.pumpWidget(
const example.ExpandedApp(),
);
await tester.pumpWidget(const example.ExpandedApp());
final Size row = tester.getSize(find.byType(Row));
expect(row, const Size(rowWidth, rowHeight));

View File

@@ -13,10 +13,10 @@ void main() {
HttpOverrides.global = null;
});
testWidgets('FittedBox scales the image to fill the parent container', (WidgetTester tester) async {
await tester.pumpWidget(
const example.FittedBoxApp(),
);
testWidgets('FittedBox scales the image to fill the parent container', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.FittedBoxApp());
final Size containerSize = tester.getSize(find.byType(Container));
expect(containerSize, const Size(300, 400));

View File

@@ -8,9 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Clicking on the menu icon opens the Flow menu', (WidgetTester tester) async {
await tester.pumpWidget(
const example.FlowApp(),
);
await tester.pumpWidget(const example.FlowApp());
// The menu icon is in the top left corner of the screen.
Offset menuIcon = tester.getCenter(find.byIcon(Icons.menu));

View File

@@ -12,11 +12,11 @@ void main() {
const double widthFactor = 0.5;
const double heightFactor = 0.5;
await tester.pumpWidget(
const example.FractionallySizedBoxApp(),
);
await tester.pumpWidget(const example.FractionallySizedBoxApp());
final FractionallySizedBox fractionallySizedBox = tester.widget(find.byType(FractionallySizedBox));
final FractionallySizedBox fractionallySizedBox = tester.widget(
find.byType(FractionallySizedBox),
);
expect(fractionallySizedBox.widthFactor, widthFactor);
expect(fractionallySizedBox.heightFactor, heightFactor);

View File

@@ -11,23 +11,30 @@ void main() {
testWidgets('IgnorePointer ignores pointer on the ElevatedButton', (WidgetTester tester) async {
const String clickButtonText = 'Click me!';
await tester.pumpWidget(
const example.IgnorePointerApp(),
);
await tester.pumpWidget(const example.IgnorePointerApp());
// The ElevatedButton is clickable.
expect(find.text('Ignoring: false'), findsOneWidget);
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse, pointer: 1);
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
pointer: 1,
);
await gesture.addPointer(location: tester.getCenter(find.text(clickButtonText)));
// On hovering the ElevatedButton, the cursor should be SystemMouseCursors.click.
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.click,
);
// Tap to set ignoring pointer to true.
await tester.tap(find.text('Set ignoring to true'));
await tester.pump();
// The ElevatedButton is not clickable so the cursor should be SystemMouseCursors.basic.
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.basic,
);
});
}

View File

@@ -11,11 +11,14 @@ void main() {
await tester.pumpWidget(const example.IndexedStackApp());
final Finder gesture2 = find.byKey(const Key('gesture2'));
final Element containerFinder = find.byKey(const Key('Dash'), skipOffstage: false).evaluate().first;
final Element containerFinder =
find.byKey(const Key('Dash'), skipOffstage: false).evaluate().first;
expect(containerFinder.renderObject!.debugNeedsPaint, false);
final Element containerFinder1 = find.byKey(const Key('John'), skipOffstage: false).evaluate().first;
final Element containerFinder1 =
find.byKey(const Key('John'), skipOffstage: false).evaluate().first;
expect(containerFinder1.renderObject!.debugNeedsPaint, true);
final Element containerFinder2 = find.byKey(const Key('Mary'), skipOffstage: false).evaluate().first;
final Element containerFinder2 =
find.byKey(const Key('Mary'), skipOffstage: false).evaluate().first;
expect(containerFinder2.renderObject!.debugNeedsPaint, true);
await tester.tap(gesture2);
@@ -34,9 +37,12 @@ void main() {
await tester.pumpWidget(const example.IndexedStackApp());
final Finder gesture1 = find.byKey(const Key('gesture1'));
final Element containerFinder = find.byKey(const Key('Dash'), skipOffstage: false).evaluate().first;
final Element containerFinder1 = find.byKey(const Key('John'), skipOffstage: false).evaluate().first;
final Element containerFinder2 = find.byKey(const Key('Mary'), skipOffstage: false).evaluate().first;
final Element containerFinder =
find.byKey(const Key('Dash'), skipOffstage: false).evaluate().first;
final Element containerFinder1 =
find.byKey(const Key('John'), skipOffstage: false).evaluate().first;
final Element containerFinder2 =
find.byKey(const Key('Mary'), skipOffstage: false).evaluate().first;
await tester.tap(gesture1);
await tester.pump();

View File

@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/basic/listener.0.dart' as example;
@@ -10,9 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Listener detects press & release, and cursor location', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(home: example.ListenerExample()),
);
await tester.pumpWidget(const MaterialApp(home: example.ListenerExample()));
expect(find.text('0 presses\n0 releases'), findsOneWidget);
expect(find.text('The cursor is here: (0.00, 0.00)'), findsOneWidget);

View File

@@ -8,10 +8,10 @@ import 'package:flutter_api_samples/widgets/basic/mouse_region.0.dart' as exampl
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('MouseRegion detects mouse entries, exists, and location', (WidgetTester tester) async {
await tester.pumpWidget(
const example.MouseRegionApp(),
);
testWidgets('MouseRegion detects mouse entries, exists, and location', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.MouseRegionApp());
expect(find.text('0 Entries\n0 Exits'), findsOneWidget);
expect(find.text('The cursor is here: (0.00, 0.00)'), findsOneWidget);
@@ -24,9 +24,7 @@ void main() {
expect(find.text('1 Entries\n0 Exits'), findsOneWidget);
expect(find.text('The cursor is here: (400.00, 328.00)'), findsOneWidget);
await gesture.moveTo(
tester.getCenter(find.byType(ColoredBox)) + const Offset(50.0, 30.0),
);
await gesture.moveTo(tester.getCenter(find.byType(ColoredBox)) + const Offset(50.0, 30.0));
await tester.pump();
expect(find.text('The cursor is here: (450.00, 358.00)'), findsOneWidget);

View File

@@ -9,9 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('MouseRegion detects mouse hover', (WidgetTester tester) async {
await tester.pumpWidget(
const example.MouseRegionApp(),
);
await tester.pumpWidget(const example.MouseRegionApp());
Container container = tester.widget<Container>(find.byType(Container));
expect(container.decoration, const BoxDecoration(color: Colors.blue));

View File

@@ -9,9 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('MouseRegion update mouse hover with a delay', (WidgetTester tester) async {
await tester.pumpWidget(
const example.MouseRegionApp(),
);
await tester.pumpWidget(const example.MouseRegionApp());
expect(find.text('Not hovering'), findsOneWidget);

View File

@@ -7,9 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Can off/on stage Flutter logo widget', (WidgetTester tester) async {
await tester.pumpWidget(
const example.OffstageApp(),
);
await tester.pumpWidget(const example.OffstageApp());
// The Flutter logo is off stage and not visible.
expect(find.text('Flutter logo is offstage: true'), findsOneWidget);

View File

@@ -7,13 +7,13 @@ import 'package:flutter_api_samples/widgets/basic/overflowbox.0.dart' as example
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('OverflowBox allows child widget to overflow parent container', (WidgetTester tester) async {
const Size containerSize = Size(100, 100);
testWidgets('OverflowBox allows child widget to overflow parent container', (
WidgetTester tester,
) async {
const Size containerSize = Size(100, 100);
const Size maxSize = Size(200, 200);
await tester.pumpWidget(
const example.OverflowBoxApp(),
);
await tester.pumpWidget(const example.OverflowBoxApp());
// The parent container has fixed width and height of 100 pixels.
expect(tester.getSize(find.byType(Container).first), containerSize);

View File

@@ -8,15 +8,10 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('PhysicalShape is an ancestor of the text widget', (WidgetTester tester) async {
await tester.pumpWidget(
const example.PhysicalShapeApp(),
);
await tester.pumpWidget(const example.PhysicalShapeApp());
final PhysicalShape physicalShape = tester.widget<PhysicalShape>(
find.ancestor(
of:find.text('Hello, World!'),
matching: find.byType(PhysicalShape),
),
find.ancestor(of: find.text('Hello, World!'), matching: find.byType(PhysicalShape)),
);
expect(physicalShape.clipper, isNotNull);
expect(physicalShape.color, Colors.orange);