withImage static method
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,
);
}