imageFromAssetBundle function

Future<ImageProvider> imageFromAssetBundle(
  1. String key, {
  2. AssetBundle? bundle,
  3. bool cache = true,
  4. PdfImageOrientation? orientation,
  5. double? dpi,
  6. PdfBaseCache? pdfCache,
})

Load an image from an asset bundle key.

Implementation

Future<ImageProvider> imageFromAssetBundle(
  String key, {
  AssetBundle? bundle,
  bool cache = true,
  PdfImageOrientation? orientation,
  double? dpi,
  PdfBaseCache? pdfCache,
}) async {
  bundle ??= rootBundle;
  final bytes = await bundle.load(key);

  return MemoryImage(
    bytes.buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes),
    orientation: orientation,
    dpi: dpi,
  );
}