diff --git a/sheet/lib/src/route/base_route_extended.dart b/sheet/lib/src/route/base_route_extended.dart index 7779d1b0..8bf6951d 100644 --- a/sheet/lib/src/route/base_route_extended.dart +++ b/sheet/lib/src/route/base_route_extended.dart @@ -73,7 +73,7 @@ class _PageBasedMaterialPageRoute extends MaterialExtendedPageRoute { @override Widget buildContent(BuildContext context) { - return builder(context); + return _page.child; } @override @@ -150,7 +150,7 @@ class _PageBasedCupertinoPageRoute extends CupertinoExtendedPageRoute { @override Widget buildContent(BuildContext context) { - return builder(context); + return _page.child; } @override diff --git a/sheet/test/src/route/base_route_extended_test.dart b/sheet/test/src/route/base_route_extended_test.dart index 9119b0f0..f9016b5c 100644 --- a/sheet/test/src/route/base_route_extended_test.dart +++ b/sheet/test/src/route/base_route_extended_test.dart @@ -55,6 +55,36 @@ void main() { expect(find.text('child'), findsOneWidget); }); + testWidgets('navigating to different routes keeping the same page', + (WidgetTester tester) async { + await tester.pumpWidget(MaterialApp( + builder: (context, child) { + return Navigator( + pages: [ + MaterialExtendedPage(child: Text('first child')), + ], + onPopPage: (route, result) => false, + ); + }, + )); + await tester.pumpAndSettle(); + expect(find.text('first child'), findsOneWidget); + + await tester.pumpWidget(MaterialApp( + builder: (context, child) { + return Navigator( + pages: [ + MaterialExtendedPage(child: Text('second child')), + ], + onPopPage: (route, result) => false, + ); + }, + )); + + await tester.pumpAndSettle(); + expect(find.text('second child'), findsOneWidget); + }); + testWidgets('route is a MaterialExtendedPageRoute', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp( @@ -156,6 +186,36 @@ void main() { expect(find.text('child'), findsOneWidget); }); + testWidgets('navigating to different routes keeping the same page', + (WidgetTester tester) async { + await tester.pumpWidget(MaterialApp( + builder: (context, child) { + return Navigator( + pages: [ + CupertinoExtendedPage(child: Text('first child')), + ], + onPopPage: (route, result) => false, + ); + }, + )); + await tester.pumpAndSettle(); + expect(find.text('first child'), findsOneWidget); + + await tester.pumpWidget(MaterialApp( + builder: (context, child) { + return Navigator( + pages: [ + CupertinoExtendedPage(child: Text('second child')), + ], + onPopPage: (route, result) => false, + ); + }, + )); + + await tester.pumpAndSettle(); + expect(find.text('second child'), findsOneWidget); + }); + testWidgets('route is a CupertinoExtendedPageRoute', (WidgetTester tester) async { await tester.pumpWidget(MaterialApp(