CNTabBar constructor
const
CNTabBar({
- Key? key,
- required List<
CNTabBarItem> items, - required int currentIndex,
- required ValueChanged<
int> onTap, - Color? tint,
- Color? backgroundColor,
- double? iconSize,
- double? height,
- bool split = false,
- int rightCount = 1,
- bool shrinkCentered = true,
- double splitSpacing = 12.0,
- CNTabBarSearchItem? searchItem,
- CNTabBarSearchController? searchController,
- String? labelFontFamily,
- double? labelFontSize,
Creates a Cupertino-native tab bar.
According to Apple's Human Interface Guidelines, tab bars should contain 3-5 tabs for optimal usability. More than 5 tabs can make the interface cluttered and reduce tappability.
Implementation
const CNTabBar({
super.key,
required this.items,
required this.currentIndex,
required this.onTap,
this.tint,
this.backgroundColor,
this.iconSize,
this.height,
this.split = false,
this.rightCount = 1,
this.shrinkCentered = true,
this.splitSpacing =
12.0, // Apple's recommended spacing for visual separation
this.searchItem,
this.searchController,
this.labelFontFamily,
this.labelFontSize,
}) : assert(items.length >= 2, 'Tab bar must have at least 2 items'),
assert(
items.length <= 5,
'Tab bar should have 5 or fewer items for optimal usability',
),
assert(rightCount >= 1, 'Right count must be at least 1'),
assert(
rightCount < items.length || searchItem != null,
'Right count must be less than total items',
);