BottomNavigationBar constructor

BottomNavigationBar({Key key, @required List<BottomNavigationBarItem> items, ValueChanged<int> onTap, int currentIndex: 0, BottomNavigationBarType type, Color fixedColor, double iconSize: 24.0 })

Creates a bottom navigation bar, typically used in a Scaffold where it is provided as the Scaffold.bottomNavigationBar argument.

The length of items must be at least two and each item's icon and title must be not null.

If type is null then BottomNavigationBarType.fixed is used when there are two or three items, BottomNavigationBarType.shifting otherwise.

If fixedColor is null then the theme's primary color, ThemeData.primaryColor, is used. However if BottomNavigationBar.type is BottomNavigationBarType.shifting then fixedColor is ignored.

Implementation

BottomNavigationBar({
  Key key,
  @required this.items,
  this.onTap,
  this.currentIndex = 0,
  BottomNavigationBarType type,
  this.fixedColor,
  this.iconSize = 24.0,
}) : assert(items != null),
     assert(items.length >= 2),
     assert(
      items.every((BottomNavigationBarItem item) => item.title != null) == true,
      'Every item must have a non-null title',
     ),
     assert(0 <= currentIndex && currentIndex < items.length),
     assert(iconSize != null),
     type = type ?? (items.length <= 3 ? BottomNavigationBarType.fixed : BottomNavigationBarType.shifting),
     super(key: key);