Showing
2 changed files
with
62 additions
and
2 deletions
| @@ -73,7 +73,7 @@ class _PageBasedMaterialPageRoute<T> extends MaterialExtendedPageRoute<T> { | @@ -73,7 +73,7 @@ class _PageBasedMaterialPageRoute<T> extends MaterialExtendedPageRoute<T> { | ||
| 73 | 73 | ||
| 74 | @override | 74 | @override |
| 75 | Widget buildContent(BuildContext context) { | 75 | Widget buildContent(BuildContext context) { |
| 76 | - return builder(context); | 76 | + return _page.child; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | @override | 79 | @override |
| @@ -150,7 +150,7 @@ class _PageBasedCupertinoPageRoute<T> extends CupertinoExtendedPageRoute<T> { | @@ -150,7 +150,7 @@ class _PageBasedCupertinoPageRoute<T> extends CupertinoExtendedPageRoute<T> { | ||
| 150 | 150 | ||
| 151 | @override | 151 | @override |
| 152 | Widget buildContent(BuildContext context) { | 152 | Widget buildContent(BuildContext context) { |
| 153 | - return builder(context); | 153 | + return _page.child; |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | @override | 156 | @override |
| @@ -55,6 +55,36 @@ void main() { | @@ -55,6 +55,36 @@ void main() { | ||
| 55 | expect(find.text('child'), findsOneWidget); | 55 | expect(find.text('child'), findsOneWidget); |
| 56 | }); | 56 | }); |
| 57 | 57 | ||
| 58 | + testWidgets('navigating to different routes keeping the same page', | ||
| 59 | + (WidgetTester tester) async { | ||
| 60 | + await tester.pumpWidget(MaterialApp( | ||
| 61 | + builder: (context, child) { | ||
| 62 | + return Navigator( | ||
| 63 | + pages: [ | ||
| 64 | + MaterialExtendedPage(child: Text('first child')), | ||
| 65 | + ], | ||
| 66 | + onPopPage: (route, result) => false, | ||
| 67 | + ); | ||
| 68 | + }, | ||
| 69 | + )); | ||
| 70 | + await tester.pumpAndSettle(); | ||
| 71 | + expect(find.text('first child'), findsOneWidget); | ||
| 72 | + | ||
| 73 | + await tester.pumpWidget(MaterialApp( | ||
| 74 | + builder: (context, child) { | ||
| 75 | + return Navigator( | ||
| 76 | + pages: [ | ||
| 77 | + MaterialExtendedPage(child: Text('second child')), | ||
| 78 | + ], | ||
| 79 | + onPopPage: (route, result) => false, | ||
| 80 | + ); | ||
| 81 | + }, | ||
| 82 | + )); | ||
| 83 | + | ||
| 84 | + await tester.pumpAndSettle(); | ||
| 85 | + expect(find.text('second child'), findsOneWidget); | ||
| 86 | + }); | ||
| 87 | + | ||
| 58 | testWidgets('route is a MaterialExtendedPageRoute', | 88 | testWidgets('route is a MaterialExtendedPageRoute', |
| 59 | (WidgetTester tester) async { | 89 | (WidgetTester tester) async { |
| 60 | await tester.pumpWidget(MaterialApp( | 90 | await tester.pumpWidget(MaterialApp( |
| @@ -156,6 +186,36 @@ void main() { | @@ -156,6 +186,36 @@ void main() { | ||
| 156 | expect(find.text('child'), findsOneWidget); | 186 | expect(find.text('child'), findsOneWidget); |
| 157 | }); | 187 | }); |
| 158 | 188 | ||
| 189 | + testWidgets('navigating to different routes keeping the same page', | ||
| 190 | + (WidgetTester tester) async { | ||
| 191 | + await tester.pumpWidget(MaterialApp( | ||
| 192 | + builder: (context, child) { | ||
| 193 | + return Navigator( | ||
| 194 | + pages: [ | ||
| 195 | + CupertinoExtendedPage(child: Text('first child')), | ||
| 196 | + ], | ||
| 197 | + onPopPage: (route, result) => false, | ||
| 198 | + ); | ||
| 199 | + }, | ||
| 200 | + )); | ||
| 201 | + await tester.pumpAndSettle(); | ||
| 202 | + expect(find.text('first child'), findsOneWidget); | ||
| 203 | + | ||
| 204 | + await tester.pumpWidget(MaterialApp( | ||
| 205 | + builder: (context, child) { | ||
| 206 | + return Navigator( | ||
| 207 | + pages: [ | ||
| 208 | + CupertinoExtendedPage(child: Text('second child')), | ||
| 209 | + ], | ||
| 210 | + onPopPage: (route, result) => false, | ||
| 211 | + ); | ||
| 212 | + }, | ||
| 213 | + )); | ||
| 214 | + | ||
| 215 | + await tester.pumpAndSettle(); | ||
| 216 | + expect(find.text('second child'), findsOneWidget); | ||
| 217 | + }); | ||
| 218 | + | ||
| 159 | testWidgets('route is a CupertinoExtendedPageRoute', | 219 | testWidgets('route is a CupertinoExtendedPageRoute', |
| 160 | (WidgetTester tester) async { | 220 | (WidgetTester tester) async { |
| 161 | await tester.pumpWidget(MaterialApp( | 221 | await tester.pumpWidget(MaterialApp( |
-
Please register or login to post a comment