Widget build()

in nav2-usability/scenario_code/lib/nested-routing/nested_routing_navi.dart [58:98]


  Widget build(BuildContext context) {
    return Scaffold(
      body: AnimatedSwitcher(
        duration: const Duration(milliseconds: 300),
        child: NaviStack(
          key: ValueKey(_currentIndex),
          pages: (context) => [
            _currentIndex == 0
                ? NaviPage.material(
                    key: ValueKey(_currentIndex),
                    route: NaviRoute(path: ['books']),
                    child: BooksScreen(),
                  )
                : NaviPage.material(
                    key: ValueKey(_currentIndex),
                    route: NaviRoute(path: ['settings']),
                    child: SettingsScreen(),
                  )
          ],
        ),
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        items: [
          BottomNavigationBarItem(
            label: 'Books',
            icon: Icon(Icons.chrome_reader_mode_outlined),
          ),
          BottomNavigationBarItem(
            label: 'Settings',
            icon: Icon(Icons.settings),
          ),
        ],
        onTap: (newIndex) {
          setState(() {
            _currentIndex = newIndex;
          });
        },
      ),
    );
  }