fromAsset static method

Future<Img> fromAsset(
  1. String key, {
  2. AssetBundle? bundle,
})

Create a Img from an asset

Parameters

  • IN key The asset key
  • IN bundle The bundle to be used. By default it is rootBundle

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);
}