asset static method

Future<AssetMapBitmap> asset(
  1. ImageConfiguration configuration,
  2. String assetName, {
  3. AssetBundle? bundle,
  4. String? package,
  5. double? width,
  6. double? height,
  7. double? imagePixelRatio,
  8. MapBitmapScaling bitmapScaling = MapBitmapScaling.auto,
})

Creates a BitmapDescriptor from an asset using AssetMapBitmap.

This method wraps AssetMapBitmap.create for ease of use within the context of creating BitmapDescriptor instances. It dynamically resolves the correct asset version based on the device's pixel ratio, ensuring optimal resolution without manual configuration.

configuration provides the image configuration for the asset. assetName is the name of the asset to load. bundle and package specify the asset's location if outside of the default. width and height can optionally control the dimensions of the rendered image. imagePixelRatio controls the scale of the image relative to the device's pixel ratio. It defaults resolved asset image pixel ratio. The value is ignored if width or height is provided.

See AssetMapBitmap.create for more information on the parameters.

Returns a Future that completes with a new AssetMapBitmap instance.

Implementation

static Future<AssetMapBitmap> asset(
  ImageConfiguration configuration,
  String assetName, {
  AssetBundle? bundle,
  String? package,
  double? width,
  double? height,
  double? imagePixelRatio,
  MapBitmapScaling bitmapScaling = MapBitmapScaling.auto,
}) async {
  return AssetMapBitmap.create(
    configuration,
    assetName,
    bundle: bundle,
    package: package,
    width: width,
    height: height,
    imagePixelRatio: imagePixelRatio,
    bitmapScaling: bitmapScaling,
  );
}