show method

BottomNavigationBar? show({
  1. List<BottomNavigationBarItem>? items,
  2. ValueChanged<int>? onTap,
  3. int? currentIndex,
  4. double? elevation,
  5. BottomNavigationBarType? type,
  6. Color? fixedColor,
  7. Color? backgroundColor,
  8. double? iconSize,
  9. Color? selectedItemColor,
  10. Color? unselectedItemColor,
  11. IconThemeData? selectedIconTheme,
  12. IconThemeData? unselectedIconTheme,
  13. double? selectedFontSize,
  14. double? unselectedFontSize,
  15. TextStyle? selectedLabelStyle,
  16. TextStyle? unselectedLabelStyle,
  17. bool? showSelectedLabels,
  18. bool? showUnselectedLabels,
  19. bool? hide,
})

Display the defined BottomNavigationBar

Implementation

BottomNavigationBar? show(
    {List<BottomNavigationBarItem>? items,
    ValueChanged<int>? onTap,
    int? currentIndex,
    double? elevation,
    BottomNavigationBarType? type,
    Color? fixedColor,
    Color? backgroundColor,
    double? iconSize,
    Color? selectedItemColor,
    Color? unselectedItemColor,
    IconThemeData? selectedIconTheme,
    IconThemeData? unselectedIconTheme,
    double? selectedFontSize,
    double? unselectedFontSize,
    TextStyle? selectedLabelStyle,
    TextStyle? unselectedLabelStyle,
    bool? showSelectedLabels,
    bool? showUnselectedLabels,
    bool? hide}) {
  // In case null was directly assigned.
  this.hide ??= false;
  hide ??= this.hide;
  if (hide!) {
    return null;
  }

  // If directly assigned an invalid index
  currentIndex ??= this.currentIndex;

  if (currentIndex == null || currentIndex < 0) {
    currentIndex = _lastIndex;
  }
  if (items != null && currentIndex > items.length - 1) {
    currentIndex = _lastIndex;
  }

  // Supply the original routine if any.
  onTap ??= this.onTap;

  return BottomNavigationBar(
    key: key,
    items: items ?? this.items!,
    onTap: (int index) {
      this.currentIndex = index;
      _lastIndex = index;
      if (onTap != null) {
        onTap(index);
      }
    },
    currentIndex: currentIndex,
    elevation: elevation ?? this.elevation ?? 8.0,
    type: type ?? this.type,
    fixedColor: fixedColor ?? this.fixedColor,
    backgroundColor: backgroundColor ?? this.backgroundColor,
    iconSize: iconSize ?? this.iconSize ?? 24.0,
    selectedItemColor: selectedItemColor ?? this.selectedItemColor,
    unselectedItemColor: unselectedItemColor ?? this.unselectedItemColor,
    selectedIconTheme:
        selectedIconTheme ?? this.selectedIconTheme ?? const IconThemeData(),
    unselectedIconTheme: unselectedIconTheme ??
        this.unselectedIconTheme ??
        const IconThemeData(),
    selectedFontSize: selectedFontSize ?? this.selectedFontSize ?? 14.0,
    unselectedFontSize: unselectedFontSize ?? this.unselectedFontSize ?? 12.0,
    selectedLabelStyle: selectedLabelStyle ?? this.selectedLabelStyle,
    unselectedLabelStyle: unselectedLabelStyle ?? this.unselectedLabelStyle,
    showSelectedLabels: showSelectedLabels ?? this.showSelectedLabels ?? true,
    showUnselectedLabels: showUnselectedLabels ?? this.showUnselectedLabels,
  );
}