1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00

Upgrading samples to flutter_lints, part 1 of n (#804)

This commit is contained in:
Brett Morgan
2021-06-05 12:24:28 +10:00
committed by GitHub
parent 14921d0c06
commit 936d1fdaae
230 changed files with 2361 additions and 2444 deletions

View File

@@ -15,7 +15,7 @@ void main() {
await tester.pumpWidget(TestingApp());
// Create variables for finders that are used multiple times.
final itemFinder = find.byKey(ValueKey('text_25'));
final itemFinder = find.byKey(const ValueKey('text_25'));
// Scroll until the item to be found appears.
await tester.scrollUntilVisible(
@@ -31,22 +31,22 @@ void main() {
await tester.pumpWidget(TestingApp());
// Create a finder for the icon.
final iconFinder = find.byKey(ValueKey('icon_0'));
final iconFinder = find.byKey(const ValueKey('icon_0'));
// Tap on the icon.
await tester.tap(iconFinder);
await tester.pumpAndSettle(Duration(seconds: 1));
await tester.pumpAndSettle(const Duration(seconds: 1));
// Verify if appropriate message appears.
expect(find.text('Added to favorites.'), findsOneWidget);
// Tap on the icon again.
await tester.tap(iconFinder);
await tester.pumpAndSettle(Duration(seconds: 1));
await tester.pumpAndSettle(const Duration(seconds: 1));
// Verify if appropriate message appears.
expect(find.text('Removed from favorites.'), findsOneWidget);
await tester.pumpAndSettle(Duration(seconds: 1));
await tester.pumpAndSettle(const Duration(seconds: 1));
});
testWidgets('Verifying whether item gets added to favorites',
@@ -54,8 +54,8 @@ void main() {
await tester.pumpWidget(TestingApp());
// Add item to favorites.
await tester.tap(find.byKey(ValueKey('icon_5')));
await tester.pumpAndSettle(Duration(seconds: 1));
await tester.tap(find.byKey(const ValueKey('icon_5')));
await tester.pumpAndSettle(const Duration(seconds: 1));
// Tap on the favorites button on the AppBar.
// The Favorites List should appear.
@@ -63,7 +63,10 @@ void main() {
await tester.pumpAndSettle();
// Check if the added item has appeared in the list.
expect(tester.widget<Text>(find.byKey(ValueKey('favorites_text_5'))).data,
expect(
tester
.widget<Text>(find.byKey(const ValueKey('favorites_text_5')))
.data,
equals('Item 5'));
});
@@ -71,16 +74,16 @@ void main() {
await tester.pumpWidget(TestingApp());
// Add item to favorites.
await tester.tap(find.byKey(ValueKey('icon_5')));
await tester.pumpAndSettle(Duration(seconds: 1));
await tester.tap(find.byKey(const ValueKey('icon_5')));
await tester.pumpAndSettle(const Duration(seconds: 1));
// Navigate to Favorites screen.
await tester.tap(find.text('Favorites'));
await tester.pumpAndSettle();
// Tap on the remove icon.
await tester.tap(find.byKey(ValueKey('remove_icon_5')));
await tester.pumpAndSettle(Duration(seconds: 1));
await tester.tap(find.byKey(const ValueKey('remove_icon_5')));
await tester.pumpAndSettle(const Duration(seconds: 1));
// Verify if it disappears.
expect(find.text('Item 5'), findsNothing);