loadImageFromPath function

Future<Image> loadImageFromPath(
  1. String path, [
  2. bool cache = true
])

Implementation

Future<ui.Image> loadImageFromPath(String path, [bool cache = true]) async {
  final file = cache
      ? await DefaultCacheManager().getSingleFile(path)
      : File(path);
  final bytes = await file.readAsBytes();
  final codec = await ui.instantiateImageCodec(bytes, allowUpscaling: false);
  return (await codec.getNextFrame()).image;
}