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
@@ -7,10 +7,10 @@ import 'package:flutter_api_samples/material/scaffold/scaffold.0.dart' as exampl
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('The count should be incremented when the floating action button is tapped', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ScaffoldExampleApp(),
|
||||
);
|
||||
testWidgets('The count should be incremented when the floating action button is tapped', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.ScaffoldExampleApp());
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne);
|
||||
expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne);
|
||||
|
||||
@@ -7,10 +7,10 @@ import 'package:flutter_api_samples/material/scaffold/scaffold.1.dart' as exampl
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('The count should be incremented when the floating action button is tapped', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ScaffoldExampleApp(),
|
||||
);
|
||||
testWidgets('The count should be incremented when the floating action button is tapped', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.ScaffoldExampleApp());
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne);
|
||||
expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne);
|
||||
|
||||
@@ -7,21 +7,22 @@ import 'package:flutter_api_samples/material/scaffold/scaffold.2.dart' as exampl
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('The count should be incremented when the centered floating action button is tapped', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ScaffoldExampleApp(),
|
||||
);
|
||||
testWidgets(
|
||||
'The count should be incremented when the centered floating action button is tapped',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.ScaffoldExampleApp());
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne);
|
||||
expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne);
|
||||
expect(find.text('You have pressed the button 0 times.'), findsOne);
|
||||
expect(find.byType(BottomAppBar), findsOne);
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)).dx, 400);
|
||||
expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne);
|
||||
expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne);
|
||||
expect(find.text('You have pressed the button 0 times.'), findsOne);
|
||||
expect(find.byType(BottomAppBar), findsOne);
|
||||
expect(tester.getCenter(find.byType(FloatingActionButton)).dx, 400);
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pump();
|
||||
expect(find.text('You have pressed the button $i times.'), findsOne);
|
||||
}
|
||||
});
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pump();
|
||||
expect(find.text('You have pressed the button $i times.'), findsOne);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ import 'package:flutter_api_samples/material/scaffold/scaffold.drawer.0.dart' as
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('The page should contain a drawer than can be opened and closed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.DrawerExampleApp(),
|
||||
);
|
||||
testWidgets('The page should contain a drawer than can be opened and closed', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.DrawerExampleApp());
|
||||
|
||||
expect(find.byType(Drawer), findsNothing);
|
||||
|
||||
@@ -19,8 +19,8 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(Drawer), findsOne);
|
||||
expect(tester.getCenter(
|
||||
find.byType(Drawer)).dx,
|
||||
expect(
|
||||
tester.getCenter(find.byType(Drawer)).dx,
|
||||
lessThan(400),
|
||||
reason: 'The drawer should be on the left side of the screen',
|
||||
);
|
||||
@@ -33,8 +33,8 @@ void main() {
|
||||
expect(find.byType(Drawer), findsNothing);
|
||||
|
||||
// Open the drawer by tapping the drawer button in the app bar.
|
||||
expect(tester.getCenter(
|
||||
find.byType(DrawerButton)).dx,
|
||||
expect(
|
||||
tester.getCenter(find.byType(DrawerButton)).dx,
|
||||
lessThan(400),
|
||||
reason: 'The drawer button should be on the left side of the app bar',
|
||||
);
|
||||
|
||||
@@ -7,10 +7,10 @@ import 'package:flutter_api_samples/material/scaffold/scaffold.end_drawer.0.dart
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('The page should contain an end drawer than can be opened and closed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.EndDrawerExampleApp(),
|
||||
);
|
||||
testWidgets('The page should contain an end drawer than can be opened and closed', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.EndDrawerExampleApp());
|
||||
|
||||
expect(find.byType(Drawer), findsNothing);
|
||||
|
||||
@@ -19,8 +19,8 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(Drawer), findsOne);
|
||||
expect(tester.getCenter(
|
||||
find.byType(Drawer)).dx,
|
||||
expect(
|
||||
tester.getCenter(find.byType(Drawer)).dx,
|
||||
greaterThan(400),
|
||||
reason: 'The drawer should be on the right side of the screen',
|
||||
);
|
||||
@@ -33,8 +33,8 @@ void main() {
|
||||
expect(find.byType(Drawer), findsNothing);
|
||||
|
||||
// Open the drawer by tapping the drawer button in the app bar.
|
||||
expect(tester.getCenter(
|
||||
find.byType(EndDrawerButton)).dx,
|
||||
expect(
|
||||
tester.getCenter(find.byType(EndDrawerButton)).dx,
|
||||
greaterThan(400),
|
||||
reason: 'The drawer button should be on the right side of the app bar',
|
||||
);
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold.floating_action_button_animator.0.dart' as example;
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold.floating_action_button_animator.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('FloatingActionButton animation can be customized', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ScaffoldFloatingActionButtonAnimatorApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.ScaffoldFloatingActionButtonAnimatorApp());
|
||||
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
|
||||
|
||||
@@ -3,63 +3,44 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold.of.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold.of.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Verify correct labels are displayed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OfExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OfExampleApp());
|
||||
|
||||
expect(find.text('Scaffold.of Example'), findsOneWidget);
|
||||
expect(find.text('SHOW BOTTOM SHEET'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Bottom sheet can be shown', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OfExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OfExampleApp());
|
||||
|
||||
expect(find.text('BottomSheet'), findsNothing);
|
||||
expect(
|
||||
find.widgetWithText(ElevatedButton, 'Close BottomSheet'),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.widgetWithText(ElevatedButton, 'Close BottomSheet'), findsNothing);
|
||||
|
||||
// Tap the button to show the bottom sheet.
|
||||
await tester.tap(
|
||||
find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'),
|
||||
);
|
||||
await tester.tap(find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('BottomSheet'), findsOneWidget);
|
||||
expect(
|
||||
find.widgetWithText(ElevatedButton, 'Close BottomSheet'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.widgetWithText(ElevatedButton, 'Close BottomSheet'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Bottom sheet can be closed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OfExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OfExampleApp());
|
||||
|
||||
expect(find.text('BottomSheet'), findsNothing);
|
||||
|
||||
// Tap the button to show the bottom sheet.
|
||||
await tester.tap(
|
||||
find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'),
|
||||
);
|
||||
await tester.tap(find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('BottomSheet'), findsOneWidget);
|
||||
|
||||
// Tap the button to close the bottom sheet.
|
||||
await tester.tap(
|
||||
find.widgetWithText(ElevatedButton, 'Close BottomSheet'),
|
||||
);
|
||||
await tester.tap(find.widgetWithText(ElevatedButton, 'Close BottomSheet'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('BottomSheet'), findsNothing);
|
||||
|
||||
@@ -3,63 +3,44 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold.of.1.dart'
|
||||
as example;
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold.of.1.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Verify correct labels are displayed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OfExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OfExampleApp());
|
||||
|
||||
expect(find.text('Scaffold.of Example'), findsOneWidget);
|
||||
expect(find.text('SHOW BOTTOM SHEET'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Bottom sheet can be shown', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OfExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OfExampleApp());
|
||||
|
||||
expect(find.text('BottomSheet'), findsNothing);
|
||||
expect(
|
||||
find.widgetWithText(ElevatedButton, 'Close BottomSheet'),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.widgetWithText(ElevatedButton, 'Close BottomSheet'), findsNothing);
|
||||
|
||||
// Tap the button to show the bottom sheet.
|
||||
await tester.tap(
|
||||
find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'),
|
||||
);
|
||||
await tester.tap(find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('BottomSheet'), findsOneWidget);
|
||||
expect(
|
||||
find.widgetWithText(ElevatedButton, 'Close BottomSheet'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.widgetWithText(ElevatedButton, 'Close BottomSheet'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Bottom sheet can be closed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OfExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OfExampleApp());
|
||||
|
||||
expect(find.text('BottomSheet'), findsNothing);
|
||||
|
||||
// Tap the button to show the bottom sheet.
|
||||
await tester.tap(
|
||||
find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'),
|
||||
);
|
||||
await tester.tap(find.widgetWithText(ElevatedButton, 'SHOW BOTTOM SHEET'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('BottomSheet'), findsOneWidget);
|
||||
|
||||
// Tap the button to close the bottom sheet.
|
||||
await tester.tap(
|
||||
find.widgetWithText(ElevatedButton, 'Close BottomSheet'),
|
||||
);
|
||||
await tester.tap(find.widgetWithText(ElevatedButton, 'Close BottomSheet'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('BottomSheet'), findsNothing);
|
||||
|
||||
@@ -7,10 +7,10 @@ import 'package:flutter_api_samples/material/scaffold/scaffold_messenger.0.dart'
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('The snack bar should be visible after tapping the button', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ScaffoldMessengerExampleApp(),
|
||||
);
|
||||
testWidgets('The snack bar should be visible after tapping the button', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.ScaffoldMessengerExampleApp());
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'ScaffoldMessenger Sample'), findsOne);
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import 'package:flutter_api_samples/material/scaffold/scaffold_messenger.of.0.da
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('The snack bar should be visible after tapping the button', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OfExampleApp(),
|
||||
);
|
||||
testWidgets('The snack bar should be visible after tapping the button', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.OfExampleApp());
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'ScaffoldMessenger.of Sample'), findsOne);
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('A snack bar is displayed after 10 taps', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.OfExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.OfExampleApp());
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'ScaffoldMessenger Demo'), findsOne);
|
||||
expect(find.text('You have pushed the button this many times:'), findsOne);
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_messenger_state.show_material_banner.0.dart' as example;
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_messenger_state.show_material_banner.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Pressing the button should show a material banner', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ShowMaterialBannerExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.ShowMaterialBannerExampleApp());
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'ScaffoldMessengerState Sample'), findsOne);
|
||||
await tester.tap(find.widgetWithText(OutlinedButton, 'Show MaterialBanner'));
|
||||
@@ -18,7 +17,10 @@ void main() {
|
||||
|
||||
expect(find.widgetWithText(MaterialBanner, 'This is a MaterialBanner'), findsOne);
|
||||
expect(
|
||||
find.descendant(of: find.byType(MaterialBanner), matching: find.widgetWithText(TextButton, 'DISMISS')),
|
||||
find.descendant(
|
||||
of: find.byType(MaterialBanner),
|
||||
matching: find.widgetWithText(TextButton, 'DISMISS'),
|
||||
),
|
||||
findsOne,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_messenger_state.show_snack_bar.0.dart' as example;
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_messenger_state.show_snack_bar.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Pressing the button should display a snack bar', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ShowSnackBarExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.ShowSnackBarExampleApp());
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'ScaffoldMessengerState Sample'), findsOne);
|
||||
await tester.tap(find.widgetWithText(OutlinedButton, 'Show SnackBar'));
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_messenger_state.show_snack_bar.1.dart' as example;
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_messenger_state.show_snack_bar.1.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Floating SnackBar is visible', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.SnackBarApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.SnackBarApp());
|
||||
|
||||
final Finder buttonFinder = find.byType(ElevatedButton);
|
||||
await tester.tap(buttonFinder.first);
|
||||
@@ -25,12 +24,13 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final AssertionError exception = tester.takeException() as AssertionError;
|
||||
const String message = 'Floating SnackBar presented off screen.\n'
|
||||
'A SnackBar with behavior property set to SnackBarBehavior.floating is fully '
|
||||
'or partially off screen because some or all the widgets provided to '
|
||||
'Scaffold.floatingActionButton, Scaffold.persistentFooterButtons and '
|
||||
'Scaffold.bottomNavigationBar take up too much vertical space.\n'
|
||||
'Consider constraining the size of these widgets to allow room for the SnackBar to be visible.';
|
||||
const String message =
|
||||
'Floating SnackBar presented off screen.\n'
|
||||
'A SnackBar with behavior property set to SnackBarBehavior.floating is fully '
|
||||
'or partially off screen because some or all the widgets provided to '
|
||||
'Scaffold.floatingActionButton, Scaffold.persistentFooterButtons and '
|
||||
'Scaffold.bottomNavigationBar take up too much vertical space.\n'
|
||||
'Consider constraining the size of these widgets to allow room for the SnackBar to be visible.';
|
||||
expect(exception.message, message);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,70 +3,70 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_messenger_state.show_snack_bar.2.dart' as example;
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_messenger_state.show_snack_bar.2.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('ScaffoldMessenger showSnackBar animation can be customized using AnimationStyle',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.SnackBarApp(),
|
||||
);
|
||||
testWidgets('ScaffoldMessenger showSnackBar animation can be customized using AnimationStyle', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.SnackBarApp());
|
||||
|
||||
// Tap the button to show the SnackBar with default animation style.
|
||||
await tester.tap(find.byType(ElevatedButton));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 125)); // Advance the animation by 125ms.
|
||||
// Tap the button to show the SnackBar with default animation style.
|
||||
await tester.tap(find.byType(ElevatedButton));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 125)); // Advance the animation by 125ms.
|
||||
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(576.7, 0.1));
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(576.7, 0.1));
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 125)); // Advance the animation by 125ms.
|
||||
await tester.pump(const Duration(milliseconds: 125)); // Advance the animation by 125ms.
|
||||
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(566, 0.1));
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(566, 0.1));
|
||||
|
||||
// Tap the close button to dismiss the SnackBar.
|
||||
await tester.tap(find.byType(IconButton));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 250)); // Advance the animation by 250ms.
|
||||
// Tap the close button to dismiss the SnackBar.
|
||||
await tester.tap(find.byType(IconButton));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 250)); // Advance the animation by 250ms.
|
||||
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(614, 0.1));
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(614, 0.1));
|
||||
|
||||
// Select custom animation style.
|
||||
await tester.tap(find.text('Custom'));
|
||||
await tester.pumpAndSettle();
|
||||
// Select custom animation style.
|
||||
await tester.tap(find.text('Custom'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Tap the button to show the SnackBar with custom animation style.
|
||||
await tester.tap(find.byType(ElevatedButton));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 1500)); // Advance the animation by 125ms.
|
||||
// Tap the button to show the SnackBar with custom animation style.
|
||||
await tester.tap(find.byType(ElevatedButton));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 1500)); // Advance the animation by 125ms.
|
||||
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(576.7, 0.1));
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(576.7, 0.1));
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 1500)); // Advance the animation by 125ms.
|
||||
await tester.pump(const Duration(milliseconds: 1500)); // Advance the animation by 125ms.
|
||||
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(566, 0.1));
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(566, 0.1));
|
||||
|
||||
// Tap the close button to dismiss the SnackBar.
|
||||
await tester.tap(find.byType(IconButton));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1)); // Advance the animation by 1sec.
|
||||
// Tap the close button to dismiss the SnackBar.
|
||||
await tester.tap(find.byType(IconButton));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1)); // Advance the animation by 1sec.
|
||||
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(614, 0.1));
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(614, 0.1));
|
||||
|
||||
// Select no animation style.
|
||||
await tester.tap(find.text('None'));
|
||||
await tester.pumpAndSettle();
|
||||
// Select no animation style.
|
||||
await tester.tap(find.text('None'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Tap the button to show the SnackBar with no animation style.
|
||||
await tester.tap(find.byType(ElevatedButton));
|
||||
await tester.pump();
|
||||
// Tap the button to show the SnackBar with no animation style.
|
||||
await tester.tap(find.byType(ElevatedButton));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(566, 0.1));
|
||||
expect(tester.getTopLeft(find.text('I am a snack bar.')).dy, closeTo(566, 0.1));
|
||||
|
||||
// Tap the close button to dismiss the SnackBar.
|
||||
await tester.tap(find.byType(IconButton));
|
||||
await tester.pump();
|
||||
// Tap the close button to dismiss the SnackBar.
|
||||
await tester.tap(find.byType(IconButton));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('I am a snack bar.'), findsNothing);
|
||||
expect(find.text('I am a snack bar.'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,14 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_state.show_bottom_sheet.0.dart' as example;
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_state.show_bottom_sheet.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('The button should show a bottom sheet when pressed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ShowBottomSheetExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.ShowBottomSheetExampleApp());
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'ScaffoldState Sample'), findsOne);
|
||||
await tester.tap(find.widgetWithText(ElevatedButton, 'showBottomSheet'));
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_state.show_bottom_sheet.1.dart' as example;
|
||||
import 'package:flutter_api_samples/material/scaffold/scaffold_state.show_bottom_sheet.1.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Scaffold showBottomSheet animation can be customized using AnimationStyle', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ShowBottomSheetExampleApp(),
|
||||
);
|
||||
testWidgets('Scaffold showBottomSheet animation can be customized using AnimationStyle', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.ShowBottomSheetExampleApp());
|
||||
|
||||
// Show the bottom sheet with default animation style.
|
||||
await tester.tap(find.widgetWithText(ElevatedButton, 'showBottomSheet'));
|
||||
|
||||
Reference in New Issue
Block a user