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,15 +3,12 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/implicit_animations/animated_align.0.dart'
as example;
import 'package:flutter_api_samples/widgets/implicit_animations/animated_align.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('AnimatedAlign animates on tap', (WidgetTester tester) async {
await tester.pumpWidget(
const example.AnimatedAlignExampleApp(),
);
await tester.pumpWidget(const example.AnimatedAlignExampleApp());
final Finder alignFinder = find.descendant(
of: find.byType(AnimatedAlign),

View File

@@ -9,43 +9,23 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('AnimatedContainer updates on tap', (WidgetTester tester) async {
await tester.pumpWidget(
const example.AnimatedContainerExampleApp(),
);
await tester.pumpWidget(const example.AnimatedContainerExampleApp());
Container container = tester.widget(
find.ancestor(
of: find.byType(AnimatedContainer),
matching: find.byType(Container),
),
);
expect(
(container.decoration! as BoxDecoration).color,
equals(Colors.blue),
);
expect(
container.constraints,
equals(const BoxConstraints.tightFor(width: 100, height: 200)),
find.ancestor(of: find.byType(AnimatedContainer), matching: find.byType(Container)),
);
expect((container.decoration! as BoxDecoration).color, equals(Colors.blue));
expect(container.constraints, equals(const BoxConstraints.tightFor(width: 100, height: 200)));
expect(container.alignment, equals(Alignment.topCenter));
await tester.tap(find.byType(FlutterLogo));
await tester.pump();
container = tester.widget(
find.ancestor(
of: find.byType(AnimatedContainer),
matching: find.byType(Container),
),
);
expect(
(container.decoration! as BoxDecoration).color,
equals(Colors.blue),
);
expect(
container.constraints,
equals(const BoxConstraints.tightFor(width: 100, height: 200)),
find.ancestor(of: find.byType(AnimatedContainer), matching: find.byType(Container)),
);
expect((container.decoration! as BoxDecoration).color, equals(Colors.blue));
expect(container.constraints, equals(const BoxConstraints.tightFor(width: 100, height: 200)));
expect(container.alignment, equals(Alignment.topCenter));
// Advance animation to the end by the 2-second duration specified in
@@ -53,19 +33,10 @@ void main() {
await tester.pump(const Duration(seconds: 2));
container = tester.widget(
find.ancestor(
of: find.byType(AnimatedContainer),
matching: find.byType(Container),
),
);
expect(
(container.decoration! as BoxDecoration).color,
equals(Colors.red),
);
expect(
container.constraints,
equals(const BoxConstraints.tightFor(width: 200, height: 100)),
find.ancestor(of: find.byType(AnimatedContainer), matching: find.byType(Container)),
);
expect((container.decoration! as BoxDecoration).color, equals(Colors.red));
expect(container.constraints, equals(const BoxConstraints.tightFor(width: 200, height: 100)));
expect(container.alignment, equals(Alignment.center));
});
}

View File

@@ -10,116 +10,78 @@ import 'package:flutter_api_samples/widgets/implicit_animations/animated_fractio
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'AnimatedFractionallySizedBox animates on tap',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.AnimatedFractionallySizedBoxExampleApp(),
);
testWidgets('AnimatedFractionallySizedBox animates on tap', (WidgetTester tester) async {
await tester.pumpWidget(const example.AnimatedFractionallySizedBoxExampleApp());
final Finder fractionallySizedBoxFinder = find.descendant(
of: find.byType(AnimatedFractionallySizedBox),
matching: find.byType(FractionallySizedBox),
);
final Finder fractionallySizedBoxFinder = find.descendant(
of: find.byType(AnimatedFractionallySizedBox),
matching: find.byType(FractionallySizedBox),
);
const double beginWidthFactor = 0.75;
const double endWidthFactor = 0.25;
const double beginHeightFactor = 0.25;
const double endHeightFactor = 0.75;
const Alignment beginAlignment = Alignment.bottomRight;
const Alignment endAlignment = Alignment.topLeft;
const double beginWidthFactor = 0.75;
const double endWidthFactor = 0.25;
const double beginHeightFactor = 0.25;
const double endHeightFactor = 0.75;
const Alignment beginAlignment = Alignment.bottomRight;
const Alignment endAlignment = Alignment.topLeft;
FractionallySizedBox fractionallySizedBox = tester.widget(
fractionallySizedBoxFinder,
);
expect(fractionallySizedBox.widthFactor, beginWidthFactor);
expect(fractionallySizedBox.heightFactor, beginHeightFactor);
expect(fractionallySizedBox.alignment, beginAlignment);
FractionallySizedBox fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, beginWidthFactor);
expect(fractionallySizedBox.heightFactor, beginHeightFactor);
expect(fractionallySizedBox.alignment, beginAlignment);
// Tap on the AnimatedFractionallySizedBoxExample to start the forward
// animation.
await tester.tap(
find.byType(example.AnimatedFractionallySizedBoxExample),
);
await tester.pump();
// Tap on the AnimatedFractionallySizedBoxExample to start the forward
// animation.
await tester.tap(find.byType(example.AnimatedFractionallySizedBoxExample));
await tester.pump();
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, beginWidthFactor);
expect(fractionallySizedBox.heightFactor, beginHeightFactor);
expect(fractionallySizedBox.alignment, beginAlignment);
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, beginWidthFactor);
expect(fractionallySizedBox.heightFactor, beginHeightFactor);
expect(fractionallySizedBox.alignment, beginAlignment);
// Advance animation to the middle.
await tester.pump(
example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2,
);
// Advance animation to the middle.
await tester.pump(example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2);
final double t =
example.AnimatedFractionallySizedBoxExampleApp.curve.transform(0.5);
final double t = example.AnimatedFractionallySizedBoxExampleApp.curve.transform(0.5);
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(
fractionallySizedBox.widthFactor,
lerpDouble(beginWidthFactor, endWidthFactor, t),
);
expect(
fractionallySizedBox.heightFactor,
lerpDouble(beginHeightFactor, endHeightFactor, t),
);
expect(
fractionallySizedBox.alignment,
Alignment.lerp(beginAlignment, endAlignment, t),
);
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, lerpDouble(beginWidthFactor, endWidthFactor, t));
expect(fractionallySizedBox.heightFactor, lerpDouble(beginHeightFactor, endHeightFactor, t));
expect(fractionallySizedBox.alignment, Alignment.lerp(beginAlignment, endAlignment, t));
// Advance animation to the end.
await tester.pump(
example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2,
);
// Advance animation to the end.
await tester.pump(example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2);
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, endWidthFactor);
expect(fractionallySizedBox.heightFactor, endHeightFactor);
expect(fractionallySizedBox.alignment, endAlignment);
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, endWidthFactor);
expect(fractionallySizedBox.heightFactor, endHeightFactor);
expect(fractionallySizedBox.alignment, endAlignment);
// Tap on the AnimatedFractionallySizedBoxExample again to start the
// reverse animation.
await tester.tap(
find.byType(example.AnimatedFractionallySizedBoxExample),
);
await tester.pump();
// Tap on the AnimatedFractionallySizedBoxExample again to start the
// reverse animation.
await tester.tap(find.byType(example.AnimatedFractionallySizedBoxExample));
await tester.pump();
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, endWidthFactor);
expect(fractionallySizedBox.heightFactor, endHeightFactor);
expect(fractionallySizedBox.alignment, endAlignment);
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, endWidthFactor);
expect(fractionallySizedBox.heightFactor, endHeightFactor);
expect(fractionallySizedBox.alignment, endAlignment);
// Advance animation to the middle.
await tester.pump(
example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2,
);
// Advance animation to the middle.
await tester.pump(example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2);
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(
fractionallySizedBox.widthFactor,
lerpDouble(endWidthFactor, beginWidthFactor, t),
);
expect(
fractionallySizedBox.heightFactor,
lerpDouble(endHeightFactor, beginHeightFactor, t),
);
expect(
fractionallySizedBox.alignment,
Alignment.lerp(endAlignment, beginAlignment, t),
);
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, lerpDouble(endWidthFactor, beginWidthFactor, t));
expect(fractionallySizedBox.heightFactor, lerpDouble(endHeightFactor, beginHeightFactor, t));
expect(fractionallySizedBox.alignment, Alignment.lerp(endAlignment, beginAlignment, t));
// Advance animation to the end.
await tester.pump(
example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2,
);
// Advance animation to the end.
await tester.pump(example.AnimatedFractionallySizedBoxExampleApp.duration ~/ 2);
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, beginWidthFactor);
expect(fractionallySizedBox.heightFactor, beginHeightFactor);
expect(fractionallySizedBox.alignment, beginAlignment);
},
);
fractionallySizedBox = tester.widget(fractionallySizedBoxFinder);
expect(fractionallySizedBox.widthFactor, beginWidthFactor);
expect(fractionallySizedBox.heightFactor, beginHeightFactor);
expect(fractionallySizedBox.alignment, beginAlignment);
});
}

View File

@@ -3,48 +3,33 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/widgets/implicit_animations/animated_padding.0.dart'
as example;
import 'package:flutter_api_samples/widgets/implicit_animations/animated_padding.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'AnimatedPadding animates on ElevatedButton tap',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.AnimatedPaddingExampleApp(),
);
testWidgets('AnimatedPadding animates on ElevatedButton tap', (WidgetTester tester) async {
await tester.pumpWidget(const example.AnimatedPaddingExampleApp());
Padding padding = tester.widget(
find.descendant(
of: find.byType(AnimatedPadding),
matching: find.byType(Padding),
),
);
expect(padding.padding, equals(EdgeInsets.zero));
Padding padding = tester.widget(
find.descendant(of: find.byType(AnimatedPadding), matching: find.byType(Padding)),
);
expect(padding.padding, equals(EdgeInsets.zero));
await tester.tap(find.byType(ElevatedButton));
await tester.pump();
await tester.tap(find.byType(ElevatedButton));
await tester.pump();
padding = tester.widget(
find.descendant(
of: find.byType(AnimatedPadding),
matching: find.byType(Padding),
),
);
expect(padding.padding, equals(EdgeInsets.zero));
padding = tester.widget(
find.descendant(of: find.byType(AnimatedPadding), matching: find.byType(Padding)),
);
expect(padding.padding, equals(EdgeInsets.zero));
// Advance animation to the end by the 2-second duration specified in
// the example app.
await tester.pump(const Duration(seconds: 2));
// Advance animation to the end by the 2-second duration specified in
// the example app.
await tester.pump(const Duration(seconds: 2));
padding = tester.widget(
find.descendant(
of: find.byType(AnimatedPadding),
matching: find.byType(Padding),
),
);
expect(padding.padding, equals(const EdgeInsets.all(100.0)));
},
);
padding = tester.widget(
find.descendant(of: find.byType(AnimatedPadding), matching: find.byType(Padding)),
);
expect(padding.padding, equals(const EdgeInsets.all(100.0)));
});
}

View File

@@ -10,82 +10,76 @@ import 'package:flutter_api_samples/widgets/implicit_animations/animated_positio
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'AnimatedPositioned animates on tap',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.AnimatedPositionedExampleApp(),
);
testWidgets('AnimatedPositioned animates on tap', (WidgetTester tester) async {
await tester.pumpWidget(const example.AnimatedPositionedExampleApp());
final Finder positionedFinder = find.descendant(
of: find.byType(AnimatedPositioned),
matching: find.byType(Positioned),
);
final Finder positionedFinder = find.descendant(
of: find.byType(AnimatedPositioned),
matching: find.byType(Positioned),
);
const double beginWidth = 50.0;
const double endWidth = 200.0;
const double beginHeight = 200.0;
const double endHeight = 50.0;
const double beginTop = 150.0;
const double endTop = 50.0;
const double beginWidth = 50.0;
const double endWidth = 200.0;
const double beginHeight = 200.0;
const double endHeight = 50.0;
const double beginTop = 150.0;
const double endTop = 50.0;
Positioned positioned = tester.widget(positionedFinder);
expect(positioned.width, beginWidth);
expect(positioned.height, beginHeight);
expect(positioned.top, beginTop);
Positioned positioned = tester.widget(positionedFinder);
expect(positioned.width, beginWidth);
expect(positioned.height, beginHeight);
expect(positioned.top, beginTop);
// Tap on the 'Tap me' text to start the forward animation.
await tester.tap(find.text('Tap me'));
await tester.pump();
// Tap on the 'Tap me' text to start the forward animation.
await tester.tap(find.text('Tap me'));
await tester.pump();
positioned = tester.widget(positionedFinder);
expect(positioned.width, beginWidth);
expect(positioned.height, beginHeight);
expect(positioned.top, beginTop);
positioned = tester.widget(positionedFinder);
expect(positioned.width, beginWidth);
expect(positioned.height, beginHeight);
expect(positioned.top, beginTop);
// Advance animation to the middle.
await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2);
// Advance animation to the middle.
await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2);
final double t =
example.AnimatedPositionedExampleApp.curve.transform(0.5);
final double t = example.AnimatedPositionedExampleApp.curve.transform(0.5);
positioned = tester.widget(positionedFinder);
expect(positioned.width, lerpDouble(beginWidth, endWidth, t));
expect(positioned.height, lerpDouble(beginHeight, endHeight, t));
expect(positioned.top, lerpDouble(beginTop, endTop, t));
positioned = tester.widget(positionedFinder);
expect(positioned.width, lerpDouble(beginWidth, endWidth, t));
expect(positioned.height, lerpDouble(beginHeight, endHeight, t));
expect(positioned.top, lerpDouble(beginTop, endTop, t));
// Advance animation to the end.
await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2);
// Advance animation to the end.
await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2);
positioned = tester.widget(positionedFinder);
expect(positioned.width, endWidth);
expect(positioned.height, endHeight);
expect(positioned.top, endTop);
positioned = tester.widget(positionedFinder);
expect(positioned.width, endWidth);
expect(positioned.height, endHeight);
expect(positioned.top, endTop);
// Tap on the 'Tap me' text again to start the reverse animation.
await tester.tap(find.text('Tap me'));
await tester.pump();
// Tap on the 'Tap me' text again to start the reverse animation.
await tester.tap(find.text('Tap me'));
await tester.pump();
positioned = tester.widget(positionedFinder);
expect(positioned.width, endWidth);
expect(positioned.height, endHeight);
expect(positioned.top, endTop);
positioned = tester.widget(positionedFinder);
expect(positioned.width, endWidth);
expect(positioned.height, endHeight);
expect(positioned.top, endTop);
// Advance animation to the middle.
await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2);
// Advance animation to the middle.
await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2);
positioned = tester.widget(positionedFinder);
expect(positioned.width, lerpDouble(endWidth, beginWidth, t));
expect(positioned.height, lerpDouble(endHeight, beginHeight, t));
expect(positioned.top, lerpDouble(endTop, beginTop, t));
positioned = tester.widget(positionedFinder);
expect(positioned.width, lerpDouble(endWidth, beginWidth, t));
expect(positioned.height, lerpDouble(endHeight, beginHeight, t));
expect(positioned.top, lerpDouble(endTop, beginTop, t));
// Advance animation to the end.
await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2);
// Advance animation to the end.
await tester.pump(example.AnimatedPositionedExampleApp.duration ~/ 2);
positioned = tester.widget(positionedFinder);
expect(positioned.width, beginWidth);
expect(positioned.height, beginHeight);
expect(positioned.top, beginTop);
},
);
positioned = tester.widget(positionedFinder);
expect(positioned.width, beginWidth);
expect(positioned.height, beginHeight);
expect(positioned.top, beginTop);
});
}

View File

@@ -8,9 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Translate FlutterLogo using AnimatedSlide', (WidgetTester tester) async {
await tester.pumpWidget(
const example.AnimatedSlideApp(),
);
await tester.pumpWidget(const example.AnimatedSlideApp());
Offset logoOffset = tester.getCenter(find.byType(FlutterLogo));
expect(logoOffset.dx, 376.0);

View File

@@ -10,75 +10,72 @@ import 'package:flutter_api_samples/widgets/implicit_animations/sliver_animated_
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'SilverAnimatedOpacity animates on FloatingActionButton tap',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.SliverAnimatedOpacityExampleApp(),
);
testWidgets('SilverAnimatedOpacity animates on FloatingActionButton tap', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.SliverAnimatedOpacityExampleApp());
final Finder fadeTransitionFinder = find.descendant(
of: find.byType(SliverAnimatedOpacity),
matching: find.byType(SliverFadeTransition),
);
final Finder fadeTransitionFinder = find.descendant(
of: find.byType(SliverAnimatedOpacity),
matching: find.byType(SliverFadeTransition),
);
const double beginOpacity = 1.0;
const double endOpacity = 0.0;
const double beginOpacity = 1.0;
const double endOpacity = 0.0;
SliverFadeTransition fadeTransition = tester.widget(fadeTransitionFinder);
expect(fadeTransition.opacity.value, beginOpacity);
SliverFadeTransition fadeTransition = tester.widget(fadeTransitionFinder);
expect(fadeTransition.opacity.value, beginOpacity);
// Tap on the FloatingActionButton to start the forward animation.
await tester.tap(find.byType(FloatingActionButton));
await tester.pump();
// Tap on the FloatingActionButton to start the forward animation.
await tester.tap(find.byType(FloatingActionButton));
await tester.pump();
fadeTransition = tester.widget(fadeTransitionFinder);
expect(fadeTransition.opacity.value, beginOpacity);
fadeTransition = tester.widget(fadeTransitionFinder);
expect(fadeTransition.opacity.value, beginOpacity);
// Advance animation to the middle.
await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2);
// Advance animation to the middle.
await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2);
fadeTransition = tester.widget(fadeTransitionFinder);
expect(
fadeTransition.opacity.value,
lerpDouble(
beginOpacity,
endOpacity,
example.SliverAnimatedOpacityExampleApp.curve.transform(0.5),
),
);
fadeTransition = tester.widget(fadeTransitionFinder);
expect(
fadeTransition.opacity.value,
lerpDouble(
beginOpacity,
endOpacity,
example.SliverAnimatedOpacityExampleApp.curve.transform(0.5),
),
);
// Advance animation to the end.
await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2);
// Advance animation to the end.
await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2);
fadeTransition = tester.widget(fadeTransitionFinder);
expect(fadeTransition.opacity.value, endOpacity);
fadeTransition = tester.widget(fadeTransitionFinder);
expect(fadeTransition.opacity.value, endOpacity);
// Tap on the FloatingActionButton again to start the reverse animation.
await tester.tap(find.byType(FloatingActionButton));
await tester.pump();
// Tap on the FloatingActionButton again to start the reverse animation.
await tester.tap(find.byType(FloatingActionButton));
await tester.pump();
fadeTransition = tester.widget(fadeTransitionFinder);
expect(fadeTransition.opacity.value, endOpacity);
fadeTransition = tester.widget(fadeTransitionFinder);
expect(fadeTransition.opacity.value, endOpacity);
// Advance animation to the middle.
await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2);
// Advance animation to the middle.
await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2);
fadeTransition = tester.widget(fadeTransitionFinder);
expect(
fadeTransition.opacity.value,
lerpDouble(
endOpacity,
beginOpacity,
example.SliverAnimatedOpacityExampleApp.curve.transform(0.5),
),
);
fadeTransition = tester.widget(fadeTransitionFinder);
expect(
fadeTransition.opacity.value,
lerpDouble(
endOpacity,
beginOpacity,
example.SliverAnimatedOpacityExampleApp.curve.transform(0.5),
),
);
// Advance animation to the end.
await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2);
// Advance animation to the end.
await tester.pump(example.SliverAnimatedOpacityExampleApp.duration ~/ 2);
fadeTransition = tester.widget(fadeTransitionFinder);
expect(fadeTransition.opacity.value, beginOpacity);
},
);
fadeTransition = tester.widget(fadeTransitionFinder);
expect(fadeTransition.opacity.value, beginOpacity);
});
}