loadImage static method

Future<BaseNavigationBarAction> loadImage({
  1. required String materialImage,
  2. String? iosImage,
  3. double imageSize = 24.0,
  4. double imageWidth = 24.0,
  5. double imageHeight = 24.0,
  6. String? label,
  7. VoidCallback? onPressed,
  8. Color? tint,
  9. double? padding,
  10. double? labelSize,
  11. String? badgeValue,
  12. Color? badgeColor,
})

Loads image bytes from assets and returns a ready-to-use withImage action.

Call this once in initState or before building and store the result in state. iosImage is loaded for iOS native rendering; falls back to materialImage.

Implementation

static Future<BaseNavigationBarAction> loadImage({
  required String materialImage,
  String? iosImage,
  double imageSize = 24.0,
  double imageWidth = 24.0,
  double imageHeight = 24.0,
  String? label,
  VoidCallback? onPressed,
  Color? tint,
  double? padding,
  double? labelSize,
  String? badgeValue,
  Color? badgeColor,
}) async {
  final String assetPath = iosImage ?? materialImage;
  final Uint8List bytes = (await rootBundle.load(assetPath)).buffer.asUint8List();
  return BaseNavigationBarAction.withImage(
    materialImage: materialImage,
    imageBytes: bytes,
    imageSize: imageSize,
    imageWidth: imageWidth,
    imageHeight: imageHeight,
    label: label,
    onPressed: onPressed,
    tint: tint,
    padding: padding,
    labelSize: labelSize,
    badgeValue: badgeValue,
    badgeColor: badgeColor,
  );
}