asset static method
- ImageConfiguration configuration,
- String assetName, {
- AssetBundle? bundle,
- String? package,
- double? width,
- double? height,
- double? imagePixelRatio,
- 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,
);
}