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('Verify the texts are displayed', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SliverDecorationExampleApp(),
);
await tester.pumpWidget(const example.SliverDecorationExampleApp());
final Finder moonText = find.text('A moon on a night sky');
expect(moonText, findsOneWidget);
@@ -19,10 +17,10 @@ void main() {
expect(blueSkyText, findsOneWidget);
});
testWidgets('Verify the sliver with key `radial-gradient` has a RadialGradient', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SliverDecorationExampleApp(),
);
testWidgets('Verify the sliver with key `radial-gradient` has a RadialGradient', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.SliverDecorationExampleApp());
final DecoratedSliver radialDecoratedSliver = tester.widget<DecoratedSliver>(
find.byKey(const ValueKey<String>('radial-gradient')),
@@ -33,20 +31,17 @@ void main() {
gradient: RadialGradient(
center: Alignment(-0.5, -0.6),
radius: 0.15,
colors: <Color>[
Color(0xFFEEEEEE),
Color(0xFF111133),
],
colors: <Color>[Color(0xFFEEEEEE), Color(0xFF111133)],
stops: <double>[0.4, 0.8],
),
),
);
});
testWidgets('Verify that the sliver with key `linear-gradient` has a LinearGradient', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SliverDecorationExampleApp(),
);
testWidgets('Verify that the sliver with key `linear-gradient` has a LinearGradient', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.SliverDecorationExampleApp());
final DecoratedSliver linearDecoratedSliver = tester.widget<DecoratedSliver>(
find.byKey(const ValueKey<String>('linear-gradient')),

View File

@@ -7,23 +7,21 @@ import 'package:flutter_api_samples/widgets/sliver/decorated_sliver.1.dart' as e
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('CustomScrollView clipBehavior is Clip.none when is Clipped is false', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: example.DecoratedSliverClipExample(),
),
);
testWidgets('CustomScrollView clipBehavior is Clip.none when is Clipped is false', (
WidgetTester tester,
) async {
await tester.pumpWidget(const MaterialApp(home: example.DecoratedSliverClipExample()));
final CustomScrollView customScrollView = tester.widget(find.byType(CustomScrollView));
expect(customScrollView.clipBehavior, equals(Clip.none));
});
testWidgets('Verify the DecoratedSliver has shadow property in decoration', (WidgetTester tester) async {
testWidgets('Verify the DecoratedSliver has shadow property in decoration', (
WidgetTester tester,
) async {
await tester.pumpWidget(
const MaterialApp(
home: example.ResizableCustomScrollView(isClipped: false),
),
const MaterialApp(home: example.ResizableCustomScrollView(isClipped: false)),
);
final DecoratedSliver decoratedSliver = tester.widget(find.byType(DecoratedSliver));

View File

@@ -8,9 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('PinnedHeaderSliver example', (WidgetTester tester) async {
await tester.pumpWidget(
const example.PinnedHeaderSliverApp(),
);
await tester.pumpWidget(const example.PinnedHeaderSliverApp());
expect(find.text('PinnedHeaderSliver'), findsOneWidget);

View File

@@ -8,14 +8,15 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('PinnedHeaderSliver iOS Settings example', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SettingsAppBarApp(),
);
await tester.pumpWidget(const example.SettingsAppBarApp());
// Verify that the app contains a header: a SliverPersistentHeader
// with an AnimatedOpacity widget below it, and a Text('Settings') below that.
expect(find.byType(PinnedHeaderSliver), findsOneWidget);
expect(find.descendant(of: find.byType(PinnedHeaderSliver), matching: find.byType(AnimatedOpacity)), findsOneWidget);
expect(
find.descendant(of: find.byType(PinnedHeaderSliver), matching: find.byType(AnimatedOpacity)),
findsOneWidget,
);
expect(find.widgetWithText(AnimatedOpacity, 'Settings'), findsOneWidget);
// Verify that the app contains a "Settings" title: a SliverToBoxAdapter
@@ -26,16 +27,23 @@ void main() {
expect(tester.widget<AnimatedOpacity>(headerOpacity).opacity, 0);
// Scroll up: the header's opacity goes to 1 and the title disappears.
await tester.timedDrag(find.byType(CustomScrollView), const Offset(0, -500), const Duration(milliseconds: 500));
await tester.timedDrag(
find.byType(CustomScrollView),
const Offset(0, -500),
const Duration(milliseconds: 500),
);
await tester.pumpAndSettle();
expect(tester.widget<AnimatedOpacity>(headerOpacity).opacity, 1);
expect(find.widgetWithText(SliverToBoxAdapter, 'Settings'), findsNothing);
// Scroll back down and we're back to where we started.
await tester.timedDrag(find.byType(CustomScrollView), const Offset(0, 500), const Duration(milliseconds: 500));
await tester.timedDrag(
find.byType(CustomScrollView),
const Offset(0, 500),
const Duration(milliseconds: 500),
);
await tester.pumpAndSettle();
expect(tester.widget<AnimatedOpacity>(headerOpacity).opacity, 0);
expect(find.widgetWithText(SliverToBoxAdapter, 'Settings'), findsOneWidget);
});
}

View File

@@ -4,15 +4,12 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_api_samples/widgets/sliver/sliver_constrained_cross_axis.0.dart'
as example;
import 'package:flutter_api_samples/widgets/sliver/sliver_constrained_cross_axis.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('SliverConstrainedCrossAxis example', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SliverConstrainedCrossAxisExampleApp(),
);
await tester.pumpWidget(const example.SliverConstrainedCrossAxisExampleApp());
final RenderSliverList renderSliverList = tester.renderObject(find.byType(SliverList));
expect(renderSliverList.constraints.crossAxisExtent, equals(200));

View File

@@ -4,22 +4,22 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_api_samples/widgets/sliver/sliver_cross_axis_group.0.dart'
as example;
import 'package:flutter_api_samples/widgets/sliver/sliver_cross_axis_group.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('SliverCrossAxisGroup example', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SliverCrossAxisGroupExampleApp(),
);
await tester.pumpWidget(const example.SliverCrossAxisGroupExampleApp());
final RenderSliverCrossAxisGroup renderSliverGroup = tester.renderObject(find.byType(SliverCrossAxisGroup));
final RenderSliverCrossAxisGroup renderSliverGroup = tester.renderObject(
find.byType(SliverCrossAxisGroup),
);
expect(renderSliverGroup, isNotNull);
final double crossAxisExtent = renderSliverGroup.constraints.crossAxisExtent;
final List<RenderSliverList> renderSliverLists = tester.renderObjectList<RenderSliverList>(find.byType(SliverList)).toList();
final List<RenderSliverList> renderSliverLists =
tester.renderObjectList<RenderSliverList>(find.byType(SliverList)).toList();
final RenderSliverList firstList = renderSliverLists[0];
final RenderSliverList secondList = renderSliverLists[1];
final RenderSliverList thirdList = renderSliverLists[2];
@@ -32,12 +32,17 @@ void main() {
expect(thirdList.constraints.crossAxisExtent, equals(expectedThirdExtent));
// Also check that the paint offsets are correct.
final RenderSliverConstrainedCrossAxis renderConstrained = tester.renderObject<RenderSliverConstrainedCrossAxis>(
find.byType(SliverConstrainedCrossAxis)
);
final RenderSliverConstrainedCrossAxis renderConstrained = tester
.renderObject<RenderSliverConstrainedCrossAxis>(find.byType(SliverConstrainedCrossAxis));
expect((firstList.parentData! as SliverPhysicalParentData).paintOffset.dx, equals(0));
expect((renderConstrained.parentData! as SliverPhysicalParentData).paintOffset.dx, equals(expectedFirstExtent));
expect((thirdList.parentData! as SliverPhysicalParentData).paintOffset.dx, equals(expectedFirstExtent + expectedSecondExtent));
expect(
(renderConstrained.parentData! as SliverPhysicalParentData).paintOffset.dx,
equals(expectedFirstExtent),
);
expect(
(thirdList.parentData! as SliverPhysicalParentData).paintOffset.dx,
equals(expectedFirstExtent + expectedSecondExtent),
);
});
}

View File

@@ -8,11 +8,11 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('SliverFloatingHeader example', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SliverFloatingHeaderApp(),
);
await tester.pumpWidget(const example.SliverFloatingHeaderApp());
final Finder headerText = find.text('SliverFloatingHeader\nScroll down a little to show\nScroll up a little to hide');
final Finder headerText = find.text(
'SliverFloatingHeader\nScroll down a little to show\nScroll up a little to hide',
);
final double headerHeight = tester.getSize(headerText).height;
await tester.drag(find.byType(CustomScrollView), Offset(0, -2 * headerHeight));

View File

@@ -4,31 +4,31 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_api_samples/widgets/sliver/sliver_main_axis_group.0.dart'
as example;
import 'package:flutter_api_samples/widgets/sliver/sliver_main_axis_group.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('SliverMainAxisGroup example', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SliverMainAxisGroupExampleApp(),
);
await tester.pumpWidget(const example.SliverMainAxisGroupExampleApp());
final RenderSliverMainAxisGroup renderSliverGroup = tester.renderObject(find.byType(SliverMainAxisGroup));
final RenderSliverMainAxisGroup renderSliverGroup = tester.renderObject(
find.byType(SliverMainAxisGroup),
);
expect(renderSliverGroup, isNotNull);
final RenderSliverPersistentHeader renderAppBar = tester.renderObject<RenderSliverPersistentHeader>(find.byType(SliverAppBar));
final RenderSliverList renderSliverList = tester.renderObject<RenderSliverList>(find.byType(SliverList));
final RenderSliverToBoxAdapter renderSliverAdapter = tester.renderObject<RenderSliverToBoxAdapter>(
find.descendant(
of: find.byType(SliverMainAxisGroup),
matching: find.byType(
SliverToBoxAdapter,
skipOffstage: false,
),
skipOffstage: false,
),
final RenderSliverPersistentHeader renderAppBar = tester
.renderObject<RenderSliverPersistentHeader>(find.byType(SliverAppBar));
final RenderSliverList renderSliverList = tester.renderObject<RenderSliverList>(
find.byType(SliverList),
);
final RenderSliverToBoxAdapter renderSliverAdapter = tester
.renderObject<RenderSliverToBoxAdapter>(
find.descendant(
of: find.byType(SliverMainAxisGroup),
matching: find.byType(SliverToBoxAdapter, skipOffstage: false),
skipOffstage: false,
),
);
// renderAppBar, renderSliverList, and renderSliverAdapter1 are part of the same sliver group.
expect(renderAppBar.geometry!.scrollExtent, equals(70.0));

View File

@@ -3,15 +3,12 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/sliver/sliver_opacity.1.dart'
as example;
import 'package:flutter_api_samples/widgets/sliver/sliver_opacity.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('SliverOpacity example', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SliverOpacityExampleApp(),
);
await tester.pumpWidget(const example.SliverOpacityExampleApp());
final Finder button = find.byType(FloatingActionButton);
final Finder opacity = find.byType(SliverOpacity);

View File

@@ -8,11 +8,11 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('SliverResizingHeader example', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SliverResizingHeaderApp(),
);
await tester.pumpWidget(const example.SliverResizingHeaderApp());
final Finder headerMaterial = find.text('SliverResizingHeader\nWith Two Optional\nLines of Text');
final Finder headerMaterial = find.text(
'SliverResizingHeader\nWith Two Optional\nLines of Text',
);
final double initialHeight = tester.getSize(headerMaterial).height;
await tester.drag(find.byType(CustomScrollView), const Offset(0, -200));

View File

@@ -2,15 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_api_samples/widgets/sliver/sliver_tree.0.dart'
as example;
import 'package:flutter_api_samples/widgets/sliver/sliver_tree.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Can toggle nodes in TreeSliver', (WidgetTester tester) async {
await tester.pumpWidget(
const example.TreeSliverExampleApp(),
);
await tester.pumpWidget(const example.TreeSliverExampleApp());
expect(find.text('Second'), findsOneWidget);
expect(find.text('alpha'), findsNothing);
// Toggle tree node.

View File

@@ -2,15 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_api_samples/widgets/sliver/sliver_tree.1.dart'
as example;
import 'package:flutter_api_samples/widgets/sliver/sliver_tree.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Can toggle nodes in TreeSliver', (WidgetTester tester) async {
await tester.pumpWidget(
const example.TreeSliverExampleApp(),
);
await tester.pumpWidget(const example.TreeSliverExampleApp());
expect(find.text('lib'), findsOneWidget);
expect(find.text('src'), findsNothing);
// Toggle tree node.