Использование icon: Image.asset("assets/home.png")
пример полного кода:
class MyTabBar extends StatefulWidget {
@override
_MyTabBarState createState() => _MyTabBarState();
}
class _MyTabBarState extends State<MyTabBar> with TickerProviderStateMixin {
int tabIndex=0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
color: Colors.white,
child: tabIndex ==0 ?BottomTabBarHome()
:tabIndex == 1? BottomTabBarMail(): BottomTabBarProfile()
),
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Image.asset("assets/home.png", color: Colors.grey,),
activeIcon: Image.asset("assets/home.png", color: Colors.blue,),
title: Text('')
),
BottomNavigationBarItem(
icon: Image.asset("assets/mail.png", color: Colors.grey,),
activeIcon: Image.asset("assets/mail.png", color: Colors.blue,),
title: Text('')
),
BottomNavigationBarItem(
icon: Image.asset("assets/account.png", color: Colors.grey,),
activeIcon: Image.asset("assets/account.png", color: Colors.blue,),
title: Text('')
)
],
currentIndex: tabIndex,
selectedItemColor: Colors.blueAccent,
onTap: (int index){
setState(() {
tabIndex = index;
});
},
),
);
}
}
class BottomTabBarHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text(" Home Screen"),
),
);
}
}
class BottomTabBarMail extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text("Mail Screen"),
),
);
}
}
class BottomTabBarProfile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text(" Profile Screen"),
),
);
}
}