loadImageFromAssets function

Future<Image> loadImageFromAssets(
  1. String assetPath, {
  2. AssetBundle? bundle,
})

从 assets 加载图片并解码为 ui.Image

Implementation

Future<ui.Image> loadImageFromAssets(
  String assetPath, {
  AssetBundle? bundle,
}) async {
  final ByteData data = await (bundle ?? rootBundle).load(assetPath);
  return decodeImageFromBytes(data.buffer.asUint8List());
}