fromAssetImage static method

Future<BitmapDescriptor> fromAssetImage(
  1. ImageConfiguration configuration,
  2. String assetName,
  3. {AssetBundle? bundle,
  4. String? package,
  5. bool mipmaps = true}

Creates a BitmapDescriptor from an asset image.

Asset images in flutter are stored per: This method takes into consideration various asset resolutions and scales the images to the right resolution depending on the dpi. Set mipmaps to false to load the exact dpi version of the image, mipmap is true by default.


static Future<BitmapDescriptor> fromAssetImage(
  ImageConfiguration configuration,
  String assetName, {
  AssetBundle? bundle,
  String? package,
  bool mipmaps = true,
}) async {
  final double? devicePixelRatio = configuration.devicePixelRatio;
  if (!mipmaps && devicePixelRatio != null) {
    return BitmapDescriptor._(<Object>[
  final AssetImage assetImage =
      AssetImage(assetName, package: package, bundle: bundle);
  final AssetBundleImageKey assetBundleImageKey =
      await assetImage.obtainKey(configuration);
  final Size? size = configuration.size;
  return BitmapDescriptor._(<Object>[
    if (kIsWeb && size != null)