bottomNavigationBar method

BottomNavigationBar bottomNavigationBar({
  1. void onTap(
    1. int
    )?,
  2. int currentIndex = 0,
  3. double? elevation,
  4. BottomNavigationBarType? type,
  5. Color? fixedColor,
  6. Color? backgroundColor,
  7. double iconSize = 24.0,
  8. Color? selectedItemColor,
  9. Color? unselectedItemColor,
  10. IconThemeData? selectedIconTheme,
  11. IconThemeData? unselectedIconTheme,
  12. double selectedFontSize = 14.0,
  13. double unselectedFontSize = 12.0,
  14. TextStyle? selectedLabelStyle,
  15. TextStyle? unselectedLabelStyle,
  16. bool? showSelectedLabels,
  17. bool? showUnselectedLabels,
  18. MouseCursor? mouseCursor,
  19. bool? enableFeedback,
  20. BottomNavigationBarLandscapeLayout? landscapeLayout,
  21. bool useLegacyColorScheme = true,
})

Creates a BottomNavigationBar widget using this list as the items.

This method provides a convenient way to create a bottom navigation bar with customizable appearance and behavior options. All parameters correspond directly to the BottomNavigationBar constructor parameters.

Parameters:

  • onTap - Callback function called when a navigation item is tapped. Receives the index of the tapped item.
  • currentIndex - The index of the currently selected item. Defaults to 0.
  • elevation - The elevation of the bottom navigation bar. If null, uses the theme's default elevation.
  • type - Defines the layout and behavior of the bottom navigation bar. Can be BottomNavigationBarType.fixed or BottomNavigationBarType.shifting.
  • fixedColor - The color of the selected item when type is fixed. Deprecated in favor of selectedItemColor.
  • backgroundColor - The background color of the bottom navigation bar.
  • iconSize - The size of all icons in the bottom navigation bar. Defaults to 24.0.
  • selectedItemColor - The color of the selected navigation item's icon and label.
  • unselectedItemColor - The color of unselected navigation items' icons and labels.
  • selectedIconTheme - The theme for selected navigation item icons.
  • unselectedIconTheme - The theme for unselected navigation item icons.
  • selectedFontSize - The font size of selected navigation item labels. Defaults to 14.0.
  • unselectedFontSize - The font size of unselected navigation item labels. Defaults to 12.0.
  • selectedLabelStyle - The text style for selected navigation item labels.
  • unselectedLabelStyle - The text style for unselected navigation item labels.
  • showSelectedLabels - Whether to show labels for selected items.
  • showUnselectedLabels - Whether to show labels for unselected items.
  • mouseCursor - The cursor to display when hovering over navigation items.
  • enableFeedback - Whether to provide haptic/audio feedback on tap.
  • landscapeLayout - Defines the layout of the bottom navigation bar in landscape orientation.
  • useLegacyColorScheme - Whether to use the legacy color scheme. Defaults to true for backward compatibility.

Returns a configured BottomNavigationBar widget.

Example:

final navigationBar = [
  BottomNavigationBarItem(
    icon: Icon(Icons.home),
    label: 'Home',
  ),
  BottomNavigationBarItem(
    icon: Icon(Icons.business),
    label: 'Business',
  ),
].bottomNavigationBar(
  currentIndex: _selectedIndex,
  selectedItemColor: Colors.amber[800],
  onTap: _onItemTapped,
);

Implementation

BottomNavigationBar bottomNavigationBar({
  void Function(int)? onTap,
  int currentIndex = 0,
  double? elevation,
  BottomNavigationBarType? type,
  Color? fixedColor,
  Color? backgroundColor,
  double iconSize = 24.0,
  Color? selectedItemColor,
  Color? unselectedItemColor,
  IconThemeData? selectedIconTheme,
  IconThemeData? unselectedIconTheme,
  double selectedFontSize = 14.0,
  double unselectedFontSize = 12.0,
  TextStyle? selectedLabelStyle,
  TextStyle? unselectedLabelStyle,
  bool? showSelectedLabels,
  bool? showUnselectedLabels,
  MouseCursor? mouseCursor,
  bool? enableFeedback,
  BottomNavigationBarLandscapeLayout? landscapeLayout,
  bool useLegacyColorScheme = true,
}) =>
    BottomNavigationBar(
      items: this,
      onTap: onTap,
      currentIndex: currentIndex,
      elevation: elevation,
      type: type,
      fixedColor: fixedColor,
      backgroundColor: backgroundColor,
      iconSize: iconSize,
      selectedItemColor: selectedItemColor,
      unselectedItemColor: unselectedItemColor,
      selectedIconTheme: selectedIconTheme,
      unselectedIconTheme: unselectedIconTheme,
      selectedLabelStyle: selectedLabelStyle,
      unselectedLabelStyle: unselectedLabelStyle,
      showSelectedLabels: showSelectedLabels,
      showUnselectedLabels: showUnselectedLabels,
      mouseCursor: mouseCursor,
      enableFeedback: enableFeedback,
      landscapeLayout: landscapeLayout,
      useLegacyColorScheme: useLegacyColorScheme,
    );