fromAsset static method
Loads an image from the app's asset bundle.
Asynchronously reads image data from the specified asset path and constructs an Img instance. The image format is auto-detected.
Parameters
key- Asset path (e.g., 'assets/icon.png')bundle- Optional bundle to load from (default: rootBundle)
Returns
- A Future resolving to an Img instance
Implementation
static Future<Img> fromAsset(String key, {AssetBundle? bundle}) async {
bundle ??= rootBundle;
final ByteData byteData = await bundle.load(key);
final ByteBuffer buffer = byteData.buffer;
final Uint8List uint8list = buffer.asUint8List();
return Img(uint8list);
}