NavigationBarTheme(
data: NavigationBarThemeData(
indicatorColor: Colors.transparent,
labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
labelTextStyle: WidgetStateProperty.all(
const TextStyle(
color: AppColors.secondary,
fontFamily: 'Pretendard',
fontSize: 10,
fontWeight: FontWeight.w500),
),
),
child: Container(
decoration: const BoxDecoration(
border:
Border(top: BorderSide(color: Color(0x33FDD0FF), width: 1)),
gradient: AppColors.backgroundGradientBottomTab,
borderRadius: BorderRadius.vertical(
top: Radius.circular(24),
),
),
child: NavigationBar(
elevation: 0,
backgroundColor: Colors.transparent,
selectedIndex: selectedIndex,
destinations: [
NavigationDestination(
label: 'HOME',
icon: SvgPicture.asset(
selectedIndex == 0 ? AppSvgs.homeActive : AppSvgs.home,
),
),
NavigationDestination(
label: 'EVENT',
icon: SvgPicture.asset(
selectedIndex == 1 ? AppSvgs.eventActive : AppSvgs.event,
),
),
NavigationDestination(
label: 'COMMUNITY',
icon: SvgPicture.asset(
selectedIndex == 2
? AppSvgs.communityActive
: AppSvgs.community,
),
),
NavigationDestination(
label: 'PROFILE',
icon: SvgPicture.asset(
selectedIndex == 3
? AppSvgs.profileActive
: AppSvgs.profile,
),
),
],
onDestinationSelected: (int index) {
log("index:$index");
onDestinationSelected(context, index);
},
),
)),
);
2
Answers
For better solution please check this link
code here
If you use BottomNavigationBar and BottomNavigationBarItem like this. It works automatically.