@@ -411,38 +411,64 @@ void main() {
411
411
});
412
412
413
413
group ('close button' , () {
414
- Future <Null > expectCloseIcon (WidgetTester tester, TargetPlatform platform, IconData expectedIcon) async {
414
+ Future <Null > expectCloseIcon (WidgetTester tester, TargetPlatform platform, IconData expectedIcon, PageRoute < void > routeBuilder () ) async {
415
415
await tester.pumpWidget (
416
416
new MaterialApp (
417
417
theme: new ThemeData (platform: platform),
418
418
home: new Scaffold (appBar: new AppBar (), body: const Text ('Page 1' )),
419
419
)
420
420
);
421
421
422
- tester.state <NavigatorState >(find.byType (Navigator )).push (new MaterialPageRoute <void >(
423
- builder: (BuildContext context) {
424
- return new Scaffold (appBar: new AppBar (), body: const Text ('Page 2' ));
425
- },
426
- fullscreenDialog: true ,
427
- ));
422
+ tester.state <NavigatorState >(find.byType (Navigator )).push (routeBuilder ());
428
423
429
424
await tester.pump ();
430
425
await tester.pump (const Duration (seconds: 1 ));
431
426
432
427
final Icon icon = tester.widget (find.byType (Icon ));
433
428
expect (icon.icon, expectedIcon);
429
+ expect (find.byType (CloseButton ), findsOneWidget);
430
+ }
431
+
432
+ PageRoute <void > materialRouteBuilder () {
433
+ return new MaterialPageRoute <void >(
434
+ builder: (BuildContext context) {
435
+ return new Scaffold (appBar: new AppBar (), body: const Text ('Page 2' ));
436
+ },
437
+ fullscreenDialog: true ,
438
+ );
439
+ }
440
+
441
+ PageRoute <void > customPageRouteBuilder () {
442
+ return new _CustomPageRoute <void >(
443
+ builder: (BuildContext context) {
444
+ return new Scaffold (appBar: new AppBar (), body: const Text ('Page 2' ));
445
+ },
446
+ fullscreenDialog: true ,
447
+ );
434
448
}
435
449
436
450
testWidgets ('Close button shows correctly on Android' , (WidgetTester tester) async {
437
- await expectCloseIcon (tester, TargetPlatform .android, Icons .close);
451
+ await expectCloseIcon (tester, TargetPlatform .android, Icons .close, materialRouteBuilder );
438
452
});
439
453
440
454
testWidgets ('Close button shows correctly on Fuchsia' , (WidgetTester tester) async {
441
- await expectCloseIcon (tester, TargetPlatform .fuchsia, Icons .close);
455
+ await expectCloseIcon (tester, TargetPlatform .fuchsia, Icons .close, materialRouteBuilder );
442
456
});
443
457
444
458
testWidgets ('Close button shows correctly on iOS' , (WidgetTester tester) async {
445
- await expectCloseIcon (tester, TargetPlatform .iOS, Icons .close);
459
+ await expectCloseIcon (tester, TargetPlatform .iOS, Icons .close, materialRouteBuilder);
460
+ });
461
+
462
+ testWidgets ('Close button shows correctly with custom page route on Android' , (WidgetTester tester) async {
463
+ await expectCloseIcon (tester, TargetPlatform .android, Icons .close, customPageRouteBuilder);
464
+ });
465
+
466
+ testWidgets ('Close button shows correctly with custom page route on Fuchsia' , (WidgetTester tester) async {
467
+ await expectCloseIcon (tester, TargetPlatform .fuchsia, Icons .close, customPageRouteBuilder);
468
+ });
469
+
470
+ testWidgets ('Close button shows correctly with custom page route on iOS' , (WidgetTester tester) async {
471
+ await expectCloseIcon (tester, TargetPlatform .iOS, Icons .close, customPageRouteBuilder);
446
472
});
447
473
});
448
474
@@ -1119,3 +1145,37 @@ class _ComputeNotchSetterState extends State<_ComputeNotchSetter> {
1119
1145
return new Container ();
1120
1146
}
1121
1147
}
1148
+
1149
+ class _CustomPageRoute <T > extends PageRoute <T > {
1150
+ _CustomPageRoute ({
1151
+ @required this .builder,
1152
+ RouteSettings settings: const RouteSettings (),
1153
+ this .maintainState: true ,
1154
+ bool fullscreenDialog: false ,
1155
+ }) : assert (builder != null ),
1156
+ super (settings: settings, fullscreenDialog: fullscreenDialog);
1157
+
1158
+ final WidgetBuilder builder;
1159
+
1160
+ @override
1161
+ Duration get transitionDuration => const Duration (milliseconds: 300 );
1162
+
1163
+ @override
1164
+ Color get barrierColor => null ;
1165
+
1166
+ @override
1167
+ String get barrierLabel => null ;
1168
+
1169
+ @override
1170
+ final bool maintainState;
1171
+
1172
+ @override
1173
+ Widget buildPage (BuildContext context, Animation <double > animation, Animation <double > secondaryAnimation) {
1174
+ return builder (context);
1175
+ }
1176
+
1177
+ @override
1178
+ Widget buildTransitions (BuildContext context, Animation <double > animation, Animation <double > secondaryAnimation, Widget child) {
1179
+ return child;
1180
+ }
1181
+ }
0 commit comments