KeyedBottomNavigationBar<T> constructor

KeyedBottomNavigationBar<T>({
  1. Key? key,
  2. required Map<T, BottomNavigationBarItem> items,
  3. List<T>? keyOrder,
  4. ValueChanged<T>? onTap,
  5. required T currentItemKey,
  6. double? elevation,
  7. BottomNavigationBarType? type,
  8. Color? fixedColor,
  9. Color? backgroundColor,
  10. double iconSize = 24.0,
  11. Color? selectedItemColor,
  12. Color? unselectedItemColor,
  13. IconThemeData? selectedIconTheme,
  14. IconThemeData? unselectedIconTheme,
  15. double selectedFontSize = 14.0,
  16. double unselectedFontSize = 12.0,
  17. TextStyle? selectedLabelStyle,
  18. TextStyle? unselectedLabelStyle,
  19. bool? showSelectedLabels,
  20. bool? showUnselectedLabels,
  21. MouseCursor? mouseCursor,
  22. bool? enableFeedback,
  23. BottomNavigationBarLandscapeLayout? landscapeLayout,
})

Constructs the bar.

If keyOrder is non-null, only the given keys will be picked from the items map.

Implementation

KeyedBottomNavigationBar({
  super.key,
  required Map<T, BottomNavigationBarItem> items,
  List<T>? keyOrder,
  ValueChanged<T>? onTap,
  required T currentItemKey,
  super.elevation,
  super.type,
  super.fixedColor,
  super.backgroundColor,
  super.iconSize,
  super.selectedItemColor,
  super.unselectedItemColor,
  super.selectedIconTheme,
  super.unselectedIconTheme,
  super.selectedFontSize,
  super.unselectedFontSize,
  super.selectedLabelStyle,
  super.unselectedLabelStyle,
  super.showSelectedLabels,
  super.showUnselectedLabels,
  super.mouseCursor,
  super.enableFeedback,
  super.landscapeLayout,
}) : super(
        items: keyOrder == null
            ? items.values.toList(growable: false)
            : keyOrder.map((key) => items[key]!).toList(growable: false),
        currentIndex: max(
          (keyOrder ?? items.keys.toList(growable: false))
              .indexOf(currentItemKey),
          0,
        ),
        onTap: (index) => onTap
            ?.call((keyOrder ?? items.keys.toList(growable: false))[index]),
      );