standardBottomNavigationBar static method
Public helper method to be used for creating a BottomNavigationBar from a list of NavigationDestinations.
Implementation
static Builder standardBottomNavigationBar({
required List<NavigationDestination> destinations,
int? currentIndex,
double iconSize = 24,
Color? backgroundColor,
ValueChanged<int>? onDestinationSelected,
}) {
return Builder(
builder: (BuildContext context) {
final NavigationBarThemeData currentNavBarTheme =
NavigationBarTheme.of(context);
return NavigationBarTheme(
data: currentNavBarTheme.copyWith(
iconTheme: WidgetStateProperty.resolveWith(
(Set<WidgetState> states) {
return currentNavBarTheme.iconTheme
?.resolve(states)
?.copyWith(size: iconSize) ??
IconTheme.of(context).copyWith(size: iconSize);
},
),
),
child: MediaQuery(
data: MediaQuery.of(context).removePadding(removeTop: true),
child: NavigationBar(
backgroundColor: backgroundColor ?? Theme.of(context).colorScheme.surface,
selectedIndex: currentIndex ?? 0,
destinations: destinations,
onDestinationSelected: onDestinationSelected,
),
),
);
},
);
}