getImageFromDisc method
Loads an image from disk and returns an Image widget.
Returns null when imageName is null/empty or when the file cannot
be found.
Implementation
Future<Image?> getImageFromDisc({
String? imageName,
String? path,
BoxFit fit = BoxFit.fill,
}) async {
if ((imageName == null || imageName.isEmpty) &&
(path == null || path.isEmpty)) {
return null;
}
final Uint8List? bytes =
await readFileAsBytes(fileName: imageName, path: path);
if (bytes == null) return null;
return Image.memory(bytes, fit: fit);
}