loadImage function

Future<Image?> loadImage(
  1. String path
)

load image from a local file or network. path can be a local file path or a network url. returns null if it can not load the image.

Implementation

Future<Image?> loadImage(String path) async {
  try {
    if (path.startsWith("https://") || path.startsWith("http://")) {
      return await loadNetworkImage(path);
    } else {
      return decodeImage(await File(path).readAsBytes());
    }
  } catch (e) {
    return null;
  }
}