CNTabBar constructor

const CNTabBar({
  1. Key? key,
  2. required List<CNTabBarItem> items,
  3. required int currentIndex,
  4. required ValueChanged<int> onTap,
  5. Color? tint,
  6. Color? backgroundColor,
  7. double? iconSize,
  8. double? height,
  9. bool split = false,
  10. int rightCount = 1,
  11. bool shrinkCentered = true,
  12. double splitSpacing = 12.0,
  13. CNTabBarSearchItem? searchItem,
  14. CNTabBarSearchController? searchController,
  15. String? labelFontFamily,
  16. 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',
     );