Skip to content

Commit 5663697

Browse files
goderbauerpull[bot]
authored andcommitted
Remove double MaterialApp wrap from api samples (flutter#150055)
The widget under test already contains a MaterialApp, so there's no need to wrap it again with one in the test. In fact, the additional MaterialApp could hide problems in the widget under test.
1 parent 318c5aa commit 5663697

27 files changed

+30
-136
lines changed

examples/api/test/material/action_buttons/action_icon_theme.0_test.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
88

99
void main() {
1010
testWidgets('Action Icon Buttons', (WidgetTester tester) async {
11-
await tester.pumpWidget(
12-
const MaterialApp(
13-
home: Scaffold(
14-
body: example.ActionIconThemeExampleApp(),
15-
),
16-
),
17-
);
18-
11+
await tester.pumpWidget(const example.ActionIconThemeExampleApp());
1912

2013
expect(find.byType(DrawerButton), findsOneWidget);
2114
final Icon drawerButtonIcon = tester.widget(

examples/api/test/material/dialog/adaptive_alert_dialog.0_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ void main() {
1010
testWidgets('Show Adaptive Alert dialog', (WidgetTester tester) async {
1111
const String dialogTitle = 'AlertDialog Title';
1212
await tester.pumpWidget(
13-
const MaterialApp(
14-
home: Scaffold(
15-
body: example.AdaptiveAlertDialogApp(),
16-
),
17-
),
13+
const example.AdaptiveAlertDialogApp(),
1814
);
1915

2016
expect(find.text(dialogTitle), findsNothing);

examples/api/test/material/dialog/alert_dialog.0_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ void main() {
1010
testWidgets('Show Alert dialog', (WidgetTester tester) async {
1111
const String dialogTitle = 'AlertDialog Title';
1212
await tester.pumpWidget(
13-
const MaterialApp(
14-
home: Scaffold(
15-
body: example.AlertDialogExampleApp(),
16-
),
17-
),
13+
const example.AlertDialogExampleApp(),
1814
);
1915

2016
expect(find.text(dialogTitle), findsNothing);

examples/api/test/material/dialog/alert_dialog.1_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ void main() {
1010
testWidgets('Show Alert dialog', (WidgetTester tester) async {
1111
const String dialogTitle = 'AlertDialog Title';
1212
await tester.pumpWidget(
13-
const MaterialApp(
14-
home: Scaffold(
15-
body: example.AlertDialogExampleApp(),
16-
),
17-
),
13+
const example.AlertDialogExampleApp(),
1814
);
1915

2016
expect(find.text(dialogTitle), findsNothing);

examples/api/test/material/dialog/dialog.0_test.dart

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:flutter/material.dart';
65
import 'package:flutter_api_samples/material/dialog/dialog.0.dart' as example;
76
import 'package:flutter_test/flutter_test.dart';
87

@@ -11,11 +10,7 @@ void main() {
1110
const String dialogText = 'This is a typical dialog.';
1211

1312
await tester.pumpWidget(
14-
const MaterialApp(
15-
home: Scaffold(
16-
body: example.DialogExampleApp(),
17-
),
18-
),
13+
const example.DialogExampleApp(),
1914
);
2015

2116
expect(find.text(dialogText), findsNothing);
@@ -33,11 +28,7 @@ void main() {
3328
const String dialogText = 'This is a fullscreen dialog.';
3429

3530
await tester.pumpWidget(
36-
const MaterialApp(
37-
home: Scaffold(
38-
body: example.DialogExampleApp(),
39-
),
40-
),
31+
const example.DialogExampleApp(),
4132
);
4233

4334
expect(find.text(dialogText), findsNothing);

examples/api/test/material/dialog/show_dialog.0_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ void main() {
1010
testWidgets('Show dialog', (WidgetTester tester) async {
1111
const String dialogTitle = 'Basic dialog title';
1212
await tester.pumpWidget(
13-
const MaterialApp(
14-
home: Scaffold(
15-
body: example.ShowDialogExampleApp(),
16-
),
17-
),
13+
const example.ShowDialogExampleApp(),
1814
);
1915

2016
expect(find.text(dialogTitle), findsNothing);

examples/api/test/material/dialog/show_dialog.1_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ void main() {
1010
testWidgets('Show dialog', (WidgetTester tester) async {
1111
const String dialogTitle = 'Basic dialog title';
1212
await tester.pumpWidget(
13-
const MaterialApp(
14-
home: Scaffold(
15-
body: example.ShowDialogExampleApp(),
16-
),
17-
),
13+
const example.ShowDialogExampleApp(),
1814
);
1915

2016
expect(find.text(dialogTitle), findsNothing);

examples/api/test/material/dialog/show_dialog.2_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ void main() {
1010
testWidgets('Show dialog', (WidgetTester tester) async {
1111
const String dialogTitle = 'Basic dialog title';
1212
await tester.pumpWidget(
13-
const MaterialApp(
14-
home: Scaffold(
15-
body: example.ShowDialogExampleApp(),
16-
),
17-
),
13+
const example.ShowDialogExampleApp(),
1814
);
1915

2016
expect(find.text(dialogTitle), findsNothing);

examples/api/test/material/divider/divider.0_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
99
void main() {
1010
testWidgets('Horizontal Divider', (WidgetTester tester) async {
1111
await tester.pumpWidget(
12-
const MaterialApp(
13-
home: Scaffold(
14-
body: example.DividerExampleApp(),
15-
),
16-
),
12+
const example.DividerExampleApp(),
1713
);
1814

1915
expect(find.byType(Divider), findsOneWidget);

examples/api/test/material/divider/divider.1_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
99
void main() {
1010
testWidgets('Horizontal Divider', (WidgetTester tester) async {
1111
await tester.pumpWidget(
12-
const MaterialApp(
13-
home: Scaffold(
14-
body: example.DividerExampleApp(),
15-
),
16-
),
12+
const example.DividerExampleApp(),
1713
);
1814

1915
expect(find.byType(Divider), findsOneWidget);

examples/api/test/material/divider/vertical_divider.0_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
99
void main() {
1010
testWidgets('Vertical Divider', (WidgetTester tester) async {
1111
await tester.pumpWidget(
12-
const MaterialApp(
13-
home: Scaffold(
14-
body: example.VerticalDividerExampleApp(),
15-
),
16-
),
12+
const example.VerticalDividerExampleApp(),
1713
);
1814

1915
expect(find.byType(VerticalDivider), findsOneWidget);

examples/api/test/material/divider/vertical_divider.1_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
99
void main() {
1010
testWidgets('Vertical Divider', (WidgetTester tester) async {
1111
await tester.pumpWidget(
12-
const MaterialApp(
13-
home: Scaffold(
14-
body: example.VerticalDividerExampleApp(),
15-
),
16-
),
12+
const example.VerticalDividerExampleApp(),
1713
);
1814

1915
expect(find.byType(VerticalDivider), findsOneWidget);

examples/api/test/material/dropdown/dropdown_button.0_test.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:flutter/material.dart';
65
import 'package:flutter_api_samples/material/dropdown/dropdown_button.0.dart' as example;
76
import 'package:flutter_test/flutter_test.dart';
87

98
void main() {
109
testWidgets('Select an item from DropdownButton', (WidgetTester tester) async {
1110
await tester.pumpWidget(
12-
const MaterialApp(
13-
home: Scaffold(
14-
body: example.DropdownButtonApp(),
15-
),
16-
),
11+
const example.DropdownButtonApp(),
1712
);
1813

1914
expect(find.text('One'), findsOneWidget);

examples/api/test/material/dropdown/dropdown_button.selected_item_builder.0_test.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:flutter/material.dart';
65
import 'package:flutter_api_samples/material/dropdown/dropdown_button.selected_item_builder.0.dart' as example;
76
import 'package:flutter_test/flutter_test.dart';
87

98
void main() {
109
testWidgets('Select an item from DropdownButton', (WidgetTester tester) async {
1110
await tester.pumpWidget(
12-
const MaterialApp(
13-
home: Scaffold(
14-
body: example.DropdownButtonApp(),
15-
),
16-
),
11+
const example.DropdownButtonApp(),
1712
);
1813

1914
expect(find.text('NYC'), findsOneWidget);

examples/api/test/material/dropdown/dropdown_button.style.0_test.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:flutter/material.dart';
65
import 'package:flutter_api_samples/material/dropdown/dropdown_button.style.0.dart' as example;
76
import 'package:flutter_test/flutter_test.dart';
87

98
void main() {
109
testWidgets('Select an item from DropdownButton', (WidgetTester tester) async {
1110
await tester.pumpWidget(
12-
const MaterialApp(
13-
home: Scaffold(
14-
body: example.DropdownButtonApp(),
15-
),
16-
),
11+
const example.DropdownButtonApp(),
1712
);
1813

1914
expect(find.text('One'), findsOneWidget);

examples/api/test/material/popup_menu/popup_menu.0_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ void main() {
1111
const String menuItem = 'Item 1';
1212

1313
await tester.pumpWidget(
14-
const MaterialApp(
15-
home: Scaffold(
16-
body: example.PopupMenuApp(),
17-
),
18-
),
14+
const example.PopupMenuApp(),
1915
);
2016

2117
expect(find.text(menuItem), findsNothing);

examples/api/test/material/popup_menu/popup_menu.1_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ void main() {
1111
const String menuItem = 'Item 1';
1212

1313
await tester.pumpWidget(
14-
const MaterialApp(
15-
home: Scaffold(
16-
body: example.PopupMenuApp(),
17-
),
18-
),
14+
const example.PopupMenuApp(),
1915
);
2016

2117
expect(find.text(menuItem), findsNothing);

examples/api/test/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// found in the LICENSE file.
44

55
import 'package:flutter/gestures.dart';
6-
import 'package:flutter/material.dart';
76
import 'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.build_default_drag_handles.0.dart'
87
as example;
98
import 'package:flutter_test/flutter_test.dart';
@@ -19,9 +18,7 @@ void main() {
1918

2019
testWidgets('Reorder list item', (WidgetTester tester) async {
2120
await tester.pumpWidget(
22-
const MaterialApp(
23-
home: example.ReorderableApp(),
24-
),
21+
const example.ReorderableApp(),
2522
);
2623

2724
expect(tester.getCenter(find.text('Item 3')).dy, 280.0);

examples/api/test/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// found in the LICENSE file.
44

55
import 'package:flutter/gestures.dart';
6-
import 'package:flutter/material.dart';
76
import 'package:flutter_api_samples/material/reorderable_list/reorderable_list_view.reorderable_list_view_builder.0.dart'
87
as example;
98
import 'package:flutter_test/flutter_test.dart';
@@ -19,9 +18,7 @@ void main() {
1918

2019
testWidgets('Reorder list item', (WidgetTester tester) async {
2120
await tester.pumpWidget(
22-
const MaterialApp(
23-
home: example.ReorderableApp(),
24-
),
21+
const example.ReorderableApp(),
2522
);
2623

2724
expect(tester.getCenter(find.text('Item 3')).dy, 252.0);

examples/api/test/material/time_picker/show_time_picker.0_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ void main() {
3030
];
3131

3232
await tester.pumpWidget(
33-
const MaterialApp(
34-
home: Scaffold(
35-
body: example.ShowTimePickerApp(),
36-
),
37-
),
33+
const example.ShowTimePickerApp(),
3834
);
3935

4036
for (final String option in options) {

examples/api/test/material/toggle_buttons/toggle_buttons.0_test.dart

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ void main() {
1313
return tester.widget<TextButton>(find.widgetWithText(TextButton, text));
1414
}
1515
await tester.pumpWidget(
16-
const MaterialApp(
17-
home: Scaffold(
18-
body: example.ToggleButtonsExampleApp(),
19-
),
20-
),
16+
const example.ToggleButtonsExampleApp(),
2117
);
2218

2319
TextButton firstButton = findButton('Apple');
@@ -51,11 +47,7 @@ void main() {
5147
return tester.widget<TextButton>(find.widgetWithText(TextButton, text));
5248
}
5349
await tester.pumpWidget(
54-
const MaterialApp(
55-
home: Scaffold(
56-
body: example.ToggleButtonsExampleApp(),
57-
),
58-
),
50+
const example.ToggleButtonsExampleApp(),
5951
);
6052

6153
TextButton firstButton = findButton('Tomatoes');
@@ -90,11 +82,7 @@ void main() {
9082
return tester.widget<TextButton>(find.widgetWithIcon(TextButton, iconData));
9183
}
9284
await tester.pumpWidget(
93-
const MaterialApp(
94-
home: Scaffold(
95-
body: example.ToggleButtonsExampleApp(),
96-
),
97-
),
85+
const example.ToggleButtonsExampleApp(),
9886
);
9987

10088
TextButton firstButton = findButton(Icons.sunny);

examples/api/test/widgets/basic/custom_multi_child_layout.0_test.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
1010
void main() {
1111
testWidgets('has four containers', (WidgetTester tester) async {
1212
await tester.pumpWidget(
13-
const MaterialApp(
14-
home: Scaffold(
15-
body: example.CustomMultiChildLayoutApp(),
16-
),
17-
),
13+
const example.CustomMultiChildLayoutApp(),
1814
);
1915
final Finder containerFinder = find.byType(Container);
2016
expect(containerFinder, findsNWidgets(4));

examples/api/test/widgets/basic/mouse_region.0_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
1010
void main() {
1111
testWidgets('MouseRegion detects mouse entries, exists, and location', (WidgetTester tester) async {
1212
await tester.pumpWidget(
13-
const MaterialApp(home: example.MouseRegionApp()),
13+
const example.MouseRegionApp(),
1414
);
1515

1616
expect(find.text('0 Entries\n0 Exits'), findsOneWidget);

examples/api/test/widgets/basic/mouse_region.on_exit.0_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
1010
void main() {
1111
testWidgets('MouseRegion detects mouse hover', (WidgetTester tester) async {
1212
await tester.pumpWidget(
13-
const MaterialApp(home: example.MouseRegionApp()),
13+
const example.MouseRegionApp(),
1414
);
1515

1616
Container container = tester.widget<Container>(find.byType(Container));

examples/api/test/widgets/basic/mouse_region.on_exit.1_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
1010
void main() {
1111
testWidgets('MouseRegion update mouse hover with a delay', (WidgetTester tester) async {
1212
await tester.pumpWidget(
13-
const MaterialApp(home: example.MouseRegionApp()),
13+
const example.MouseRegionApp(),
1414
);
1515

1616
expect(find.text('Not hovering'), findsOneWidget);

0 commit comments

Comments
 (0)