...
class _MyHomePageState extends State<MyHomePage> {
int _currentIndex = 0;
final tabs = [
Center(child: Text("Home")),
Center(child: Text("Search")),
];
@override
Widget build(BuildContext context) {
return Scaffold(
...
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
type: BottomNavigationBarType.fixed,
selectedFontSize: 15,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: "Home",
backgroundColor: Colors.blue,
),
BottomNavigationBarItem(
icon: Icon(Icons.search),
label: "Search",
backgroundColor: Colors.red,
),
],
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
),
);
}
}
Copyright 2021 M. Fadli Zein