buildByMaterial method

  1. @override
Widget buildByMaterial(
  1. BuildContext context
)

build on material mode

Implementation

@override
Widget buildByMaterial(BuildContext context) {
  final ValueChanged<int>? onTap = valueOf('onTap', this.onTap);
  final bool useMaterial3 = valueOf('useMaterial3Tabs', useMaterial3Tabs);

  // Enhanced onTap with haptic feedback
  ValueChanged<int>? enhancedOnTap;
  if (onTap != null) {
    enhancedOnTap = (int index) {
      if (valueOf('hapticFeedback', hapticFeedback) && valueOf('adaptiveInteraction', adaptiveInteraction)) {
        HapticFeedback.selectionClick();
      }
      onTap(index);
    };
  }

  Widget tabBar;

  if (useMaterial3) {
    // Use Material 3 NavigationBar for modern tab design
    tabBar = NavigationBar(
      destinations: _convertToNavigationDestinations(),
      onDestinationSelected: enhancedOnTap,
      selectedIndex: valueOf('currentIndex', currentIndex) ?? 0,
      backgroundColor: valueOf('backgroundColor', backgroundColor),
      elevation: valueOf('elevation', elevation),
    );
  } else {
    // Use legacy BottomNavigationBar
    tabBar = BottomNavigationBar(
      items: valueOf('items', items),
      onTap: enhancedOnTap,
      currentIndex: valueOf('currentIndex', currentIndex) ?? 0,
      elevation: valueOf('elevation', elevation),
      type: valueOf('type', type),
      fixedColor: valueOf('fixedColor', fixedColor),
      backgroundColor: valueOf('backgroundColor', backgroundColor),
      iconSize: valueOf('iconSize', iconSize) ?? 24.0,
      selectedItemColor: valueOf('selectedItemColor', selectedItemColor),
      unselectedItemColor: valueOf('unselectedItemColor', unselectedItemColor),
      selectedIconTheme: valueOf('selectedIconTheme', selectedIconTheme),
      unselectedIconTheme: valueOf('unselectedIconTheme', unselectedIconTheme),
      selectedFontSize: valueOf('selectedFontSize', selectedFontSize),
      unselectedFontSize: valueOf('unselectedFontSize', unselectedFontSize),
      selectedLabelStyle: valueOf('selectedLabelStyle', selectedLabelStyle),
      unselectedLabelStyle: valueOf('unselectedLabelStyle', unselectedLabelStyle),
      showSelectedLabels: valueOf('showSelectedLabels', showSelectedLabels),
      showUnselectedLabels: valueOf('showUnselectedLabels', showUnselectedLabels),
      mouseCursor: valueOf('mouseCursor', mouseCursor),
      enableFeedback: valueOf('enableFeedback', enableFeedback),
    );
  }

  // Apply iOS 26 Liquid Glass effects if enabled
  // if (valueOf('enableLiquidGlass', enableLiquidGlass)) {
  //   return _wrapWithLiquidGlass(context, tabBar);
  // }

  return tabBar;
}