Skip to content

Commit

Permalink
fixes issue 343 (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skogsfrae authored Jun 18, 2023
1 parent 62c5428 commit 3917484
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sheet/lib/src/route/base_route_extended.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class _PageBasedMaterialPageRoute<T> extends MaterialExtendedPageRoute<T> {

@override
Widget buildContent(BuildContext context) {
return builder(context);
return _page.child;
}

@override
Expand Down Expand Up @@ -150,7 +150,7 @@ class _PageBasedCupertinoPageRoute<T> extends CupertinoExtendedPageRoute<T> {

@override
Widget buildContent(BuildContext context) {
return builder(context);
return _page.child;
}

@override
Expand Down
60 changes: 60 additions & 0 deletions sheet/test/src/route/base_route_extended_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 3917484

Please sign in to comment.