import 'package:flutter/material.dart'; import 'package:physigo/exercises/exercises_page.dart'; import 'package:physigo/friends/friends_page.dart'; import 'package:physigo/home/home_page.dart'; import 'package:physigo/ranking/ranking_page.dart'; class MainPage extends StatefulWidget { const MainPage({Key? key}) : super(key: key); @override State createState() => _MainPage(); } class _MainPage extends State { static const List _widgets = [ HomePage(), ExercisesPage(), RankingPage(), FriendsPage(), ]; int _selectedIndex = 0; void _onMenuTap(int newIndex) { setState(() { _selectedIndex = newIndex; }); } @override Widget build(BuildContext context) { return SafeArea( child: Scaffold( bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, // need to specify fixed with more than 3 items currentIndex: _selectedIndex, onTap: _onMenuTap, items: const [ BottomNavigationBarItem(icon: Icon(Icons.home), label: "Home"), BottomNavigationBarItem(icon: Icon(Icons.sports_gymnastics), label: "Exercises"), BottomNavigationBarItem(icon: Icon(Icons.emoji_events), label: "Ranking"), BottomNavigationBarItem(icon: Icon(Icons.people), label: "Social"), ], ), body: _widgets[_selectedIndex], ), ); } }