fromAssetImage static method
- @Deprecated('Use BitmapDescriptor.asset method instead.')
- ImageConfiguration configuration,
- String assetName, {
- AssetBundle? bundle,
- String? package,
- bool mipmaps = true,
Creates a BitmapDescriptor from an asset image.
Asset images in flutter are stored per:
https://flutter.dev/to/resolution-aware-images
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.
Implementation
@Deprecated('Use BitmapDescriptor.asset method instead.')
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 AssetImageBitmap(name: assetName, scale: devicePixelRatio);
}
final AssetImage assetImage =
AssetImage(assetName, package: package, bundle: bundle);
final AssetBundleImageKey assetBundleImageKey =
await assetImage.obtainKey(configuration);
final Size? size = kIsWeb ? configuration.size : null;
return AssetImageBitmap(
name: assetBundleImageKey.name,
scale: assetBundleImageKey.scale,
size: size);
}