import
'package:flutter/material.dart'
;
class
BottomBar extends StatefulWidget {
@override
_BottomBarState createState() => _BottomBarState();
}
class
_BottomBarState extends State<BottomBar> {
int
currentIndex = 0;
setBottomBarIndex(index){
setState(() {
currentIndex = index;
});
}
final tabs = [
Center(child: Text(
"Home"
,style: TextStyle(color: Colors.white))),
Center(child: Text(
"Cart"
,style: TextStyle(color: Colors.white))),
Center(child: Text(
"Profile"
,style: TextStyle(color: Colors.white))),
Center(child: Text(
"Folder"
,style: TextStyle(color: Colors.white))),
Center(child: Text(
"Add Items"
,style: TextStyle(color: Colors.white))),
];
@override
Widget build(BuildContext context) {
return
Scaffold(
appBar: AppBar(
title: Text(
"Geeks for Geeks"
),
),
backgroundColor: Colors.white10,
body: tabs[currentIndex],
floatingActionButton: FloatingActionButton(
onPressed: (){
setBottomBarIndex(4);
},
child: Icon(Icons.add,color: Colors.white),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: BottomAppBar(
color: Colors.white,
shape: CircularNotchedRectangle(),
child: Container(
height: 80,
padding: EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(Icons.home,
color: currentIndex == 0 ? Colors.green : Colors.grey,
),
onPressed: (){
setBottomBarIndex(0);
},
splashColor: Colors.white,
),
IconButton(
icon: Icon(Icons.add_shopping_cart,
color: currentIndex == 1 ? Colors.green : Colors.grey,
),
onPressed: (){
setBottomBarIndex(1);
}),
SizedBox.shrink(),
IconButton(
icon: Icon(Icons.person,
color: currentIndex == 2 ? Colors.green : Colors.grey,
),
onPressed: (){
setBottomBarIndex(2);
}),
IconButton(
icon: Icon(Icons.insert_drive_file,
color: currentIndex == 3 ? Colors.green : Colors.grey,
),
onPressed: (){
setBottomBarIndex(3);
}),
],
),
),
),
);
}
}