in nav2-usability/scenario_code/lib/nested-routing/router.dart [145:196]
Widget _overlayEntryBuilder(BuildContext context) {
return Scaffold(
body: Navigator(
key: navigatorKey,
pages: [
if (_appState.page == AppPage.settings)
FadeTransitionPage(
key: ValueKey('SettingsScreen'),
child: SettingsScreen(),
),
if (_appState.page == AppPage.newBooks ||
_appState.page == AppPage.allBooks)
FadeTransitionPage(
key: ValueKey('BooksScreen'),
child: BooksScreen(
onTabSelected: (int idx) {
if (idx == 0) {
_appState.page = AppPage.newBooks;
} else {
_appState.page = AppPage.allBooks;
}
},
appPage: _appState.page,
),
),
],
onPopPage: (route, result) {
return route.didPop(result);
},
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _appState.page == AppPage.settings ? 1 : 0,
onTap: (idx) {
if (idx == 0) {
_appState.page = AppPage.newBooks;
} else {
_appState.page = AppPage.settings;
}
},
items: [
BottomNavigationBarItem(
label: 'Books',
icon: Icon(Icons.chrome_reader_mode_outlined),
),
BottomNavigationBarItem(
label: 'Settings',
icon: Icon(Icons.settings),
),
],
),
);
}