fix(shell): keep the tab destination ready behind pushed pages

This commit is contained in:
2026-10-24 11:14:10 +01:00
parent 399d520c71
commit 877c2f1acd
3 changed files with 43 additions and 41 deletions
+30 -18
View File
@@ -100,22 +100,34 @@ void main() {
);
});
testWidgets('an open detail fills a phone screen without the tab bar', (
tester,
) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
Widget shell({required bool detail}) => MaterialApp(
home: AdaptiveShell(
destination: AppDestination.runs,
detailOpen: detail,
destinationBodies: {AppDestination.runs: (_) => const Text('runs')},
),
);
await tester.pumpWidget(shell(detail: false));
expect(find.byType(NavigationBar), findsOneWidget);
await tester.pumpWidget(shell(detail: true));
expect(find.byType(NavigationBar), findsNothing);
});
testWidgets(
'a pushed detail covers tabs without unmounting the Back destination',
(tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
Widget shell() => MaterialApp(
home: AdaptiveShell(
destination: AppDestination.runs,
destinationBodies: {AppDestination.runs: (_) => const Text('runs')},
),
);
await tester.pumpWidget(shell());
expect(find.byType(NavigationBar), findsOneWidget);
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
navigator.push(
MaterialPageRoute<void>(
builder: (_) => const Scaffold(body: Text('detail')),
),
);
await tester.pumpAndSettle();
expect(find.byType(NavigationBar), findsNothing);
expect(find.byType(NavigationBar, skipOffstage: false), findsOneWidget);
await navigator.maybePop();
await tester.pump(const Duration(milliseconds: 16));
expect(find.byType(NavigationBar), findsOneWidget);
await tester.pumpAndSettle();
expect(find.byType(NavigationBar), findsOneWidget);
},
);
}