getImageFromDisc method

Future<Image?> getImageFromDisc({
  1. String? imageName,
  2. String? path,
  3. BoxFit fit = BoxFit.fill,
})
  • returns the Image or null if image do not exist. It takes imageName if image is in files directory or the the entire path of the image.

Implementation

Future<Image?> getImageFromDisc(
    {String? imageName, String? path, BoxFit fit = BoxFit.fill}) async {
  if (imageName == null || imageName.isEmpty) return null;
  return Image.memory(
      (await DiscData.instance
          .readFileAsBytes(fileName: imageName, path: path))!,
      fit: fit);
}