I have bottom navigation implemented and I listed pages inside stateful widget class with list Widget as explained in official documentation. But on tap nothing is happening. Did I miss anything? Sorry if the question is too obvious, here is my code:
class _LevelSelectionScreenState extends State<LevelSelectionScreen> {
int currentPageIndex = 0;
final destinations = [
const MainMenuScreen(),
const AvailabilityScreen(),
const SettingsScreen(),
];
@override
Widget build(BuildContext context) {
final playerProgress = context.watch<PlayerProgress>();
return Scaffold(
extendBody: true,
bottomNavigationBar:
Container(
child: NavigationBar(
onDestinationSelected: (int index) {
setState(() {
currentPageIndex = index;
});
},
destinations: const <Widget>[
NavigationDestination(
selectedIcon: Icon(Icons.home),
icon: Icon(Icons.home_outlined),
label: 'Home',
),
NavigationDestination(
selectedIcon: Icon(Icons.book),
icon: Icon(Icons.book_outlined),
label: 'Learn',
),
NavigationDestination(
selectedIcon: Icon(Icons.person),
icon: Icon(Icons.person_outlined),
label: 'Profile',
),
],
),
),
),
body:
ResponsiveScreen(
.....
),
)
);
[currentPageIndex];
}
}
Full code: https://gist.github.com/ElenaEpstein/0c271bd8f3252eb30edae685831c4cb9