fromAssetImage static method

Future<BitmapDescriptor> fromAssetImage(
  1. ImageConfiguration configuration,
  2. String assetName, {
  3. AssetBundle? bundle,
  4. String? package,
})

Creates a BitmapDescriptor from an asset image. Asset images in flutter are stored per: https://flutter.dev/docs/development/ui/assets-and-images#declaring-resolution-aware-image-assets

This method takes into consideration various asset resolutions and scales the images to the right resolution depending on the dpi.

Don't forget to rebuild the map with the new Icons if it was already build.

Implementation

static Future<BitmapDescriptor> fromAssetImage(
  ImageConfiguration configuration,
  String assetName, {
  AssetBundle? bundle,
  String? package,
}) async {
  dynamic bitmap;
  if (Platform.isIOS) {
    bitmap = await appleMaps.BitmapDescriptor.fromAssetImage(
      configuration,
      assetName,
      bundle: bundle,
      package: package,
    );
  } else if (Platform.isAndroid) {
    bitmap = await googleMaps.BitmapDescriptor.fromAssetImage(
      configuration,
      assetName,
      bundle: bundle,
      package: package,
    );
  }
  return BitmapDescriptor._(bitmap);
}