forked from firka/flutter
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:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -11,8 +11,9 @@ void main() {
|
||||
await tester.pumpWidget(const example.AlignTransitionExampleApp());
|
||||
expect(find.byType(ColoredBox), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget padding) => padding is Padding
|
||||
&& padding.padding == const EdgeInsets.all(8.0)),
|
||||
find.byWidgetPredicate(
|
||||
(Widget padding) => padding is Padding && padding.padding == const EdgeInsets.all(8.0),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
@@ -22,28 +23,19 @@ void main() {
|
||||
testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.AlignTransitionExampleApp());
|
||||
final Finder paddingFinder = find.byWidgetPredicate(
|
||||
(Widget padding) => padding is Padding
|
||||
&& padding.padding == const EdgeInsets.all(8.0));
|
||||
|
||||
expect(
|
||||
tester.getBottomLeft(paddingFinder),
|
||||
tester.getBottomLeft(find.byType(AlignTransition)),
|
||||
(Widget padding) => padding is Padding && padding.padding == const EdgeInsets.all(8.0),
|
||||
);
|
||||
|
||||
expect(tester.getBottomLeft(paddingFinder), tester.getBottomLeft(find.byType(AlignTransition)));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
tester.getCenter(paddingFinder),
|
||||
tester.getCenter(find.byType(AlignTransition)),
|
||||
);
|
||||
expect(tester.getCenter(paddingFinder), tester.getCenter(find.byType(AlignTransition)));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
tester.getBottomLeft(paddingFinder),
|
||||
tester.getBottomLeft(find.byType(AlignTransition)),
|
||||
);
|
||||
expect(tester.getBottomLeft(paddingFinder), tester.getBottomLeft(find.byType(AlignTransition)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,18 +13,28 @@ void main() {
|
||||
await tester.pumpWidget(const example.AnimatedBuilderExampleApp());
|
||||
expect(find.text('Whee!'), findsOneWidget);
|
||||
expect(find.byType(Container), findsOneWidget);
|
||||
expect(tester.widget(find.byType(Container)), isA<Container>()
|
||||
.having((Container container) => container.color, 'color', Colors.green));
|
||||
expect(
|
||||
tester.widget(find.byType(Container)),
|
||||
isA<Container>().having((Container container) => container.color, 'color', Colors.green),
|
||||
);
|
||||
|
||||
expect(find.byWidgetPredicate((Widget widget) => widget is Transform
|
||||
&& widget.transform == Transform.rotate(angle: 0.0).transform),
|
||||
findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) =>
|
||||
widget is Transform && widget.transform == Transform.rotate(angle: 0.0).transform,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 5));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byWidgetPredicate((Widget widget) => widget is Transform
|
||||
&& widget.transform == Transform.rotate(angle: math.pi).transform),
|
||||
findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) =>
|
||||
widget is Transform && widget.transform == Transform.rotate(angle: math.pi).transform,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,18 +12,28 @@ void main() {
|
||||
testWidgets('Rotates green container', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.AnimatedWidgetExampleApp());
|
||||
expect(find.byType(Container), findsOneWidget);
|
||||
expect(tester.widget(find.byType(Container)), isA<Container>()
|
||||
.having((Container container) => container.color, 'color', Colors.green));
|
||||
expect(
|
||||
tester.widget(find.byType(Container)),
|
||||
isA<Container>().having((Container container) => container.color, 'color', Colors.green),
|
||||
);
|
||||
|
||||
expect(find.byWidgetPredicate((Widget widget) => widget is Transform
|
||||
&& widget.transform == Transform.rotate(angle: 0.0).transform),
|
||||
findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) =>
|
||||
widget is Transform && widget.transform == Transform.rotate(angle: 0.0).transform,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 5));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byWidgetPredicate((Widget widget) => widget is Transform
|
||||
&& widget.transform == Transform.rotate(angle: math.pi).transform),
|
||||
findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) =>
|
||||
widget is Transform && widget.transform == Transform.rotate(angle: math.pi).transform,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,36 +11,35 @@ void main() {
|
||||
await tester.pumpWidget(const example.DecoratedBoxTransitionExampleApp());
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Center), findsOneWidget);
|
||||
expect(find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(FlutterLogo)
|
||||
), findsOneWidget);
|
||||
expect(find.ancestor(
|
||||
of: find.byType(FlutterLogo),
|
||||
matching: find.byType(Container)
|
||||
), findsAtLeast(1));
|
||||
expect(
|
||||
find.descendant(of: find.byType(Center), matching: find.byType(FlutterLogo)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.ancestor(of: find.byType(FlutterLogo), matching: find.byType(Container)),
|
||||
findsAtLeast(1),
|
||||
);
|
||||
expect(find.byType(DecoratedBoxTransition), findsOneWidget);
|
||||
|
||||
expect(
|
||||
tester.widget(find.byType(DecoratedBoxTransition)),
|
||||
isA<DecoratedBoxTransition>()
|
||||
.having(
|
||||
(DecoratedBoxTransition transition) => transition.decoration.value,
|
||||
'decoration',
|
||||
BoxDecoration(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
border: Border.all(style: BorderStyle.none),
|
||||
borderRadius: BorderRadius.circular(60.0),
|
||||
boxShadow: const <BoxShadow>[
|
||||
BoxShadow(
|
||||
color: Color(0x66666666),
|
||||
blurRadius: 10.0,
|
||||
spreadRadius: 3.0,
|
||||
offset: Offset(0, 6.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
isA<DecoratedBoxTransition>().having(
|
||||
(DecoratedBoxTransition transition) => transition.decoration.value,
|
||||
'decoration',
|
||||
BoxDecoration(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
border: Border.all(style: BorderStyle.none),
|
||||
borderRadius: BorderRadius.circular(60.0),
|
||||
boxShadow: const <BoxShadow>[
|
||||
BoxShadow(
|
||||
color: Color(0x66666666),
|
||||
blurRadius: 10.0,
|
||||
spreadRadius: 3.0,
|
||||
offset: Offset(0, 6.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 3));
|
||||
@@ -48,19 +47,16 @@ void main() {
|
||||
|
||||
expect(
|
||||
tester.widget(find.byType(DecoratedBoxTransition)),
|
||||
isA<DecoratedBoxTransition>()
|
||||
.having(
|
||||
(DecoratedBoxTransition transition) => transition.decoration.value,
|
||||
'decoration',
|
||||
BoxDecoration(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
border: Border.all(
|
||||
style: BorderStyle.none,
|
||||
),
|
||||
borderRadius: BorderRadius.zero,
|
||||
// No shadow.
|
||||
),
|
||||
isA<DecoratedBoxTransition>().having(
|
||||
(DecoratedBoxTransition transition) => transition.decoration.value,
|
||||
'decoration',
|
||||
BoxDecoration(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
border: Border.all(style: BorderStyle.none),
|
||||
borderRadius: BorderRadius.zero,
|
||||
// No shadow.
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/default_text_style_transition.0.dart' as example;
|
||||
import 'package:flutter_api_samples/widgets/transitions/default_text_style_transition.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
@@ -12,45 +13,39 @@ void main() {
|
||||
expect(find.byType(Center), findsOneWidget);
|
||||
expect(find.byType(Text), findsOneWidget);
|
||||
expect(find.text('Flutter'), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(Text)
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.descendant(of: find.byType(Center), matching: find.byType(Text)), findsOneWidget);
|
||||
expect(find.byType(DefaultTextStyleTransition), findsOneWidget);
|
||||
expect(tester.widget(find.byType(DefaultTextStyleTransition)),
|
||||
isA<DefaultTextStyleTransition>()
|
||||
.having(
|
||||
(DefaultTextStyleTransition transition) => transition.style.value,
|
||||
'style',
|
||||
const TextStyle(fontSize: 50, color: Colors.blue, fontWeight: FontWeight.w900),
|
||||
),
|
||||
expect(
|
||||
tester.widget(find.byType(DefaultTextStyleTransition)),
|
||||
isA<DefaultTextStyleTransition>().having(
|
||||
(DefaultTextStyleTransition transition) => transition.style.value,
|
||||
'style',
|
||||
const TextStyle(fontSize: 50, color: Colors.blue, fontWeight: FontWeight.w900),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.widget(find.byType(DefaultTextStyleTransition)),
|
||||
isA<DefaultTextStyleTransition>()
|
||||
.having(
|
||||
(DefaultTextStyleTransition transition) => transition.style.value,
|
||||
'style',
|
||||
const TextStyle(fontSize: 50, color: Colors.red, fontWeight: FontWeight.w100),
|
||||
),
|
||||
expect(
|
||||
tester.widget(find.byType(DefaultTextStyleTransition)),
|
||||
isA<DefaultTextStyleTransition>().having(
|
||||
(DefaultTextStyleTransition transition) => transition.style.value,
|
||||
'style',
|
||||
const TextStyle(fontSize: 50, color: Colors.red, fontWeight: FontWeight.w100),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.widget(find.byType(DefaultTextStyleTransition)),
|
||||
isA<DefaultTextStyleTransition>()
|
||||
.having(
|
||||
(DefaultTextStyleTransition transition) => transition.style.value,
|
||||
'style',
|
||||
const TextStyle(fontSize: 50, color: Colors.blue, fontWeight: FontWeight.w900),
|
||||
),
|
||||
expect(
|
||||
tester.widget(find.byType(DefaultTextStyleTransition)),
|
||||
isA<DefaultTextStyleTransition>().having(
|
||||
(DefaultTextStyleTransition transition) => transition.style.value,
|
||||
'style',
|
||||
const TextStyle(fontSize: 50, color: Colors.blue, fontWeight: FontWeight.w900),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,29 +5,21 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/fade_transition.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_api_samples/widgets/transitions/fade_transition.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows FlutterLogo inside a FadeTransition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.FadeTransitionExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.FadeTransitionExampleApp());
|
||||
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: find.byType(FlutterLogo),
|
||||
matching: find.byType(FadeTransition),
|
||||
),
|
||||
find.ancestor(of: find.byType(FlutterLogo), matching: find.byType(FadeTransition)),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('FadeTransition animates', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.FadeTransitionExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.FadeTransitionExampleApp());
|
||||
|
||||
final Finder fadeTransitionFinder = find.ancestor(
|
||||
of: find.byType(FlutterLogo),
|
||||
@@ -41,41 +33,27 @@ void main() {
|
||||
expect(fadeTransition.opacity.value, equals(beginOpacity));
|
||||
|
||||
// Advance animation to the middle.
|
||||
await tester.pump(
|
||||
example.FadeTransitionExampleApp.duration ~/ 2,
|
||||
);
|
||||
await tester.pump(example.FadeTransitionExampleApp.duration ~/ 2);
|
||||
|
||||
final double t = example.FadeTransitionExampleApp.curve.transform(0.5);
|
||||
|
||||
fadeTransition = tester.widget(fadeTransitionFinder);
|
||||
expect(
|
||||
fadeTransition.opacity.value,
|
||||
equals(lerpDouble(beginOpacity, endOpacity, t)),
|
||||
);
|
||||
expect(fadeTransition.opacity.value, equals(lerpDouble(beginOpacity, endOpacity, t)));
|
||||
|
||||
// Advance animation to the end.
|
||||
await tester.pump(
|
||||
example.FadeTransitionExampleApp.duration ~/ 2,
|
||||
);
|
||||
await tester.pump(example.FadeTransitionExampleApp.duration ~/ 2);
|
||||
|
||||
fadeTransition = tester.widget(fadeTransitionFinder);
|
||||
expect(fadeTransition.opacity.value, equals(endOpacity));
|
||||
|
||||
// Advance animation to the middle.
|
||||
await tester.pump(
|
||||
example.FadeTransitionExampleApp.duration ~/ 2,
|
||||
);
|
||||
await tester.pump(example.FadeTransitionExampleApp.duration ~/ 2);
|
||||
|
||||
fadeTransition = tester.widget(fadeTransitionFinder);
|
||||
expect(
|
||||
fadeTransition.opacity.value,
|
||||
equals(lerpDouble(beginOpacity, endOpacity, t)),
|
||||
);
|
||||
expect(fadeTransition.opacity.value, equals(lerpDouble(beginOpacity, endOpacity, t)));
|
||||
|
||||
// Advance animation to the end.
|
||||
await tester.pump(
|
||||
example.FadeTransitionExampleApp.duration ~/ 2,
|
||||
);
|
||||
await tester.pump(example.FadeTransitionExampleApp.duration ~/ 2);
|
||||
|
||||
fadeTransition = tester.widget(fadeTransitionFinder);
|
||||
expect(fadeTransition.opacity.value, equals(beginOpacity));
|
||||
|
||||
@@ -10,7 +10,13 @@ void main() {
|
||||
testWidgets('Changing focus changes border', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.ListenableBuilderExample());
|
||||
|
||||
Finder findContainer() => find.descendant(of: find.byType(example.FocusListenerContainer), matching: find.byType(Container)).first;
|
||||
Finder findContainer() =>
|
||||
find
|
||||
.descendant(
|
||||
of: find.byType(example.FocusListenerContainer),
|
||||
matching: find.byType(Container),
|
||||
)
|
||||
.first;
|
||||
Finder findChild() => find.descendant(of: findContainer(), matching: find.byType(Column)).first;
|
||||
bool childHasFocus() => Focus.of(tester.element(findChild())).hasFocus;
|
||||
Container getContainer() => tester.widget(findContainer()) as Container;
|
||||
|
||||
@@ -10,7 +10,15 @@ void main() {
|
||||
testWidgets('Tapping FAB increments counter', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.ListenableBuilderExample());
|
||||
|
||||
String getCount() => (tester.widget(find.descendant(of: find.byType(ListenableBuilder).last, matching: find.byType(Text))) as Text).data!;
|
||||
String getCount() =>
|
||||
(tester.widget(
|
||||
find.descendant(
|
||||
of: find.byType(ListenableBuilder).last,
|
||||
matching: find.byType(Text),
|
||||
),
|
||||
)
|
||||
as Text)
|
||||
.data!;
|
||||
|
||||
expect(find.text('Current counter value:'), findsOneWidget);
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
|
||||
@@ -12,11 +12,10 @@ void main() {
|
||||
expect(find.text('ListenableBuilder Example'), findsOneWidget);
|
||||
expect(find.text('Current counter value:'), findsOneWidget);
|
||||
expect(find.byIcon(Icons.add), findsOneWidget);
|
||||
expect(find.descendant(
|
||||
of: find.byType(FloatingActionButton),
|
||||
matching: find.byIcon(Icons.add)
|
||||
), findsOneWidget);
|
||||
|
||||
expect(
|
||||
find.descendant(of: find.byType(FloatingActionButton), matching: find.byIcon(Icons.add)),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
expect(find.text('1'), findsNothing);
|
||||
|
||||
@@ -10,25 +10,18 @@ void main() {
|
||||
testWidgets('Tapping FAB adds to values', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.ListenableBuilderExample());
|
||||
|
||||
final Finder listContent = find.byWidgetPredicate((Widget widget) => widget is example.ListBody);
|
||||
final Finder listContent = find.byWidgetPredicate(
|
||||
(Widget widget) => widget is example.ListBody,
|
||||
);
|
||||
|
||||
expect(find.text('Current values:'), findsOneWidget);
|
||||
expect(find.byIcon(Icons.add), findsOneWidget);
|
||||
expect(
|
||||
(tester.widget(listContent) as example.ListBody).listNotifier.values.isEmpty,
|
||||
isTrue,
|
||||
);
|
||||
expect((tester.widget(listContent) as example.ListBody).listNotifier.values.isEmpty, isTrue);
|
||||
|
||||
await tester.tap(find.byType(FloatingActionButton).first);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
(tester.widget(listContent) as example.ListBody).listNotifier.values.isEmpty,
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
(tester.widget(listContent) as example.ListBody).listNotifier.values,
|
||||
<int>[1464685455],
|
||||
);
|
||||
expect((tester.widget(listContent) as example.ListBody).listNotifier.values.isEmpty, isFalse);
|
||||
expect((tester.widget(listContent) as example.ListBody).listNotifier.values, <int>[1464685455]);
|
||||
expect(find.text('1464685455'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Shows Flutter logo inside a MatrixTransition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MatrixTransitionExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.MatrixTransitionExampleApp());
|
||||
|
||||
final Finder transformFinder = find.ancestor(
|
||||
of: find.byType(FlutterLogo),
|
||||
@@ -20,9 +18,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('MatrixTransition animates', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MatrixTransitionExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.MatrixTransitionExampleApp());
|
||||
|
||||
final Finder transformFinder = find.ancestor(
|
||||
of: find.byType(FlutterLogo),
|
||||
@@ -33,12 +29,27 @@ void main() {
|
||||
Matrix4 actualTransform = transformBox.transform;
|
||||
|
||||
// Check initial transform.
|
||||
expect(actualTransform, Matrix4.fromList(<double>[
|
||||
1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.004, 1.0,
|
||||
])..transpose());
|
||||
expect(
|
||||
actualTransform,
|
||||
Matrix4.fromList(<double>[
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.004,
|
||||
1.0,
|
||||
])..transpose(),
|
||||
);
|
||||
|
||||
// Animate half way.
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
@@ -46,11 +57,28 @@ void main() {
|
||||
actualTransform = transformBox.transform;
|
||||
|
||||
// The transform should be updated.
|
||||
expect(actualTransform, isNot(Matrix4.fromList(<double>[
|
||||
1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 0.004, 1.0,
|
||||
])..transpose()));
|
||||
expect(
|
||||
actualTransform,
|
||||
isNot(
|
||||
Matrix4.fromList(<double>[
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.004,
|
||||
1.0,
|
||||
])..transpose(),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,26 +17,44 @@ void main() {
|
||||
testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.PositionedTransitionExampleApp());
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0));
|
||||
expect(
|
||||
tester.getSize(find.byType(FlutterLogo)),
|
||||
const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0),
|
||||
);
|
||||
expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
final Size canvasSize = tester.getSize(find.byType(LayoutBuilder));
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0));
|
||||
expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0));
|
||||
expect(
|
||||
tester.getSize(find.byType(FlutterLogo)),
|
||||
const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0),
|
||||
);
|
||||
expect(
|
||||
tester.getBottomRight(find.byType(FlutterLogo)),
|
||||
Offset(canvasSize.width - 8.0, canvasSize.height - 8.0),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0));
|
||||
expect(
|
||||
tester.getSize(find.byType(FlutterLogo)),
|
||||
const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0),
|
||||
);
|
||||
expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0));
|
||||
expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0));
|
||||
expect(
|
||||
tester.getSize(find.byType(FlutterLogo)),
|
||||
const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0),
|
||||
);
|
||||
expect(
|
||||
tester.getBottomRight(find.byType(FlutterLogo)),
|
||||
Offset(canvasSize.width - 8.0, canvasSize.height - 8.0),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/widgets/transitions/relative_positioned_transition.0.dart' as example;
|
||||
import 'package:flutter_api_samples/widgets/transitions/relative_positioned_transition.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
@@ -17,26 +18,44 @@ void main() {
|
||||
testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.RelativePositionedTransitionExampleApp());
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0));
|
||||
expect(
|
||||
tester.getSize(find.byType(FlutterLogo)),
|
||||
const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0),
|
||||
);
|
||||
expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
final Size canvasSize = tester.getSize(find.byType(LayoutBuilder));
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0));
|
||||
expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0));
|
||||
expect(
|
||||
tester.getSize(find.byType(FlutterLogo)),
|
||||
const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0),
|
||||
);
|
||||
expect(
|
||||
tester.getBottomRight(find.byType(FlutterLogo)),
|
||||
Offset(canvasSize.width - 8.0, canvasSize.height - 8.0),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0));
|
||||
expect(
|
||||
tester.getSize(find.byType(FlutterLogo)),
|
||||
const Size(200.0 - 2.0 * 8.0, 200.0 - 2.0 * 8.0),
|
||||
);
|
||||
expect(tester.getTopLeft(find.byType(FlutterLogo)), const Offset(8.0, 8.0));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.getSize(find.byType(FlutterLogo)), const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0));
|
||||
expect(tester.getBottomRight(find.byType(FlutterLogo)), Offset(canvasSize.width - 8.0, canvasSize.height - 8.0));
|
||||
expect(
|
||||
tester.getSize(find.byType(FlutterLogo)),
|
||||
const Size(100.0 - 2.0 * 8.0, 100.0 - 2.0 * 8.0),
|
||||
);
|
||||
expect(
|
||||
tester.getBottomRight(find.byType(FlutterLogo)),
|
||||
Offset(canvasSize.width - 8.0, canvasSize.height - 8.0),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,37 +10,46 @@ void main() {
|
||||
testWidgets('Shows flutter logo in rotation transition', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.RotationTransitionExampleApp());
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) => widget is RotationTransition
|
||||
&& widget.turns is CurvedAnimation
|
||||
&& (widget.turns as CurvedAnimation).curve == Curves.elasticOut,
|
||||
), findsOneWidget);
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) =>
|
||||
widget is RotationTransition &&
|
||||
widget.turns is CurvedAnimation &&
|
||||
(widget.turns as CurvedAnimation).curve == Curves.elasticOut,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Padding), findsAtLeast(1));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(FlutterLogo)
|
||||
),
|
||||
find.descendant(of: find.byType(Center), matching: find.byType(FlutterLogo)),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) => widget is RotationTransition
|
||||
&& widget.turns is CurvedAnimation
|
||||
&& widget.turns.value == 0.0
|
||||
&& widget.turns.status == AnimationStatus.forward
|
||||
), findsOneWidget);
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) =>
|
||||
widget is RotationTransition &&
|
||||
widget.turns is CurvedAnimation &&
|
||||
widget.turns.value == 0.0 &&
|
||||
widget.turns.status == AnimationStatus.forward,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 3));
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) => widget is RotationTransition
|
||||
&& widget.turns is CurvedAnimation
|
||||
&& (widget.turns as CurvedAnimation).parent is AnimationController
|
||||
&& ((widget.turns as CurvedAnimation).parent as AnimationController).value == 0.5
|
||||
&& widget.turns.status == AnimationStatus.reverse
|
||||
), findsOneWidget);
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) =>
|
||||
widget is RotationTransition &&
|
||||
widget.turns is CurvedAnimation &&
|
||||
(widget.turns as CurvedAnimation).parent is AnimationController &&
|
||||
((widget.turns as CurvedAnimation).parent as AnimationController).value == 0.5 &&
|
||||
widget.turns.status == AnimationStatus.reverse,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,22 +11,26 @@ void main() {
|
||||
await tester.pumpWidget(const example.ScaleTransitionExampleApp());
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Center), findsOneWidget);
|
||||
expect(find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(ScaleTransition)
|
||||
), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate((Widget widget) => widget is ScaleTransition
|
||||
&& widget.scale is CurvedAnimation
|
||||
&& (widget.scale as CurvedAnimation).curve == Curves.fastOutSlowIn,
|
||||
), findsOneWidget);
|
||||
find.descendant(of: find.byType(Center), matching: find.byType(ScaleTransition)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) =>
|
||||
widget is ScaleTransition &&
|
||||
widget.scale is CurvedAnimation &&
|
||||
(widget.scale as CurvedAnimation).curve == Curves.fastOutSlowIn,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Scales every 2 seconds', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.ScaleTransitionExampleApp());
|
||||
final Finder transformFinder = find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(Transform)
|
||||
matching: find.byType(Transform),
|
||||
);
|
||||
|
||||
Transform transform = tester.widget(transformFinder);
|
||||
|
||||
@@ -11,22 +11,36 @@ void main() {
|
||||
await tester.pumpWidget(const example.SizeTransitionExampleApp());
|
||||
expect(find.byType(FlutterLogo), findsOneWidget);
|
||||
expect(find.byType(Center), findsOneWidget);
|
||||
expect(find.descendant(
|
||||
of: find.byType(Center),
|
||||
matching: find.byType(FlutterLogo)
|
||||
), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(of: find.byType(Center), matching: find.byType(FlutterLogo)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(SizeTransition), findsOneWidget);
|
||||
|
||||
expect(
|
||||
tester.widget(find.byType(SizeTransition)),
|
||||
isA<SizeTransition>()
|
||||
.having((SizeTransition transition) => transition.axis, 'axis', Axis.horizontal)
|
||||
.having((SizeTransition transition) => transition.axisAlignment, 'axis alignment', -1)
|
||||
.having((SizeTransition transition) => transition.sizeFactor, 'factor', isA<CurvedAnimation>()
|
||||
.having((CurvedAnimation animation) => animation.curve, 'curve', Curves.fastOutSlowIn)
|
||||
.having((CurvedAnimation animation) => animation.parent, 'paren', isA<AnimationController>()
|
||||
.having((AnimationController controller) => controller.duration, 'duration', const Duration(seconds: 3)))
|
||||
)
|
||||
.having((SizeTransition transition) => transition.axis, 'axis', Axis.horizontal)
|
||||
.having((SizeTransition transition) => transition.axisAlignment, 'axis alignment', -1)
|
||||
.having(
|
||||
(SizeTransition transition) => transition.sizeFactor,
|
||||
'factor',
|
||||
isA<CurvedAnimation>()
|
||||
.having(
|
||||
(CurvedAnimation animation) => animation.curve,
|
||||
'curve',
|
||||
Curves.fastOutSlowIn,
|
||||
)
|
||||
.having(
|
||||
(CurvedAnimation animation) => animation.parent,
|
||||
'paren',
|
||||
isA<AnimationController>().having(
|
||||
(AnimationController controller) => controller.duration,
|
||||
'duration',
|
||||
const Duration(seconds: 3),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,10 +19,7 @@ void main() {
|
||||
testWidgets('Animates repeatedly every 2 seconds', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.SlideTransitionExampleApp());
|
||||
|
||||
expect(
|
||||
tester.getCenter(find.byType(FlutterLogo)),
|
||||
tester.getCenter(find.byType(Center)),
|
||||
);
|
||||
expect(tester.getCenter(find.byType(FlutterLogo)), tester.getCenter(find.byType(Center)));
|
||||
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
@@ -36,9 +33,6 @@ void main() {
|
||||
await tester.pump(const Duration(seconds: 2));
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
tester.getCenter(find.byType(FlutterLogo)),
|
||||
tester.getCenter(find.byType(Center)),
|
||||
);
|
||||
expect(tester.getCenter(find.byType(FlutterLogo)), tester.getCenter(find.byType(Center)));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -13,14 +13,18 @@ void main() {
|
||||
expect(find.text('SliverFadeTransition Sample'), findsOneWidget);
|
||||
expect(find.byType(SliverFadeTransition), findsOneWidget);
|
||||
expect(find.byType(CustomScrollView), findsOneWidget);
|
||||
expect(find.byWidgetPredicate(
|
||||
(Widget widget) => widget is Container &&
|
||||
widget.color == Colors.indigo[200]
|
||||
), findsNWidgets(3));
|
||||
expect(find.byWidgetPredicate(
|
||||
(Widget widget) => widget is Container &&
|
||||
widget.color == Colors.orange[200]
|
||||
), findsNWidgets(2));
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) => widget is Container && widget.color == Colors.indigo[200],
|
||||
),
|
||||
findsNWidgets(3),
|
||||
);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(Widget widget) => widget is Container && widget.color == Colors.orange[200],
|
||||
),
|
||||
findsNWidgets(2),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Animates repeatedly every second', (WidgetTester tester) async {
|
||||
@@ -28,8 +32,11 @@ void main() {
|
||||
|
||||
expect(
|
||||
tester.renderObject(find.byType(SliverFadeTransition)),
|
||||
isA<RenderSliverAnimatedOpacity>()
|
||||
.having((RenderSliverAnimatedOpacity obj) => obj.opacity.value, 'opacity', 0.0)
|
||||
isA<RenderSliverAnimatedOpacity>().having(
|
||||
(RenderSliverAnimatedOpacity obj) => obj.opacity.value,
|
||||
'opacity',
|
||||
0.0,
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
@@ -37,8 +44,11 @@ void main() {
|
||||
|
||||
expect(
|
||||
tester.renderObject(find.byType(SliverFadeTransition)),
|
||||
isA<RenderSliverAnimatedOpacity>()
|
||||
.having((RenderSliverAnimatedOpacity obj) => obj.opacity.value, 'opacity', 1.0)
|
||||
isA<RenderSliverAnimatedOpacity>().having(
|
||||
(RenderSliverAnimatedOpacity obj) => obj.opacity.value,
|
||||
'opacity',
|
||||
1.0,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user