withImage static method

BottomNavigationBarItem withImage({
  1. required String materialImage,
  2. String? iosImage,
  3. double imageSize = 28.0,
  4. double width = 24.0,
  5. double height = 24.0,
  6. String? label,
  7. Widget? activeIcon,
  8. String? tooltip,
  9. Color? backgroundColor,
})

Create a BottomNavigationBarItem with custom image for native iOS tab bars

Uses CNTabBarItem's native image property on iOS for better performance.

Example:

BottomNavigationBarItemNativeExtension.withImage(
  materialImage: 'assets/icons/custom.png',
  iosImage: 'assets/icons/custom_ios.png', // Optional
  imageSize: 28.0, // iOS size in points
  label: 'Custom',
)

Implementation

static BottomNavigationBarItem withImage({
  required String materialImage,
  String? iosImage,
  double imageSize = 28.0,
  double width = 24.0,
  double height = 24.0,
  String? label,
  Widget? activeIcon,
  String? tooltip,
  Color? backgroundColor,
}) {
  // Create the icon with BaseCustomImageKey metadata
  final Widget icon = Image.asset(
    materialImage,
    key: BaseCustomImageKey(
      materialImage: materialImage,
      iosImage: iosImage,
      imageSize: imageSize,
      width: width,
      height: height,
    ),
    width: width,
    height: height,
  );

  return BottomNavigationBarItem(
    icon: icon,
    activeIcon: activeIcon,
    label: label,
    tooltip: tooltip,
    backgroundColor: backgroundColor,
  );
}