imageProviderToImage static method

Future<Image> imageProviderToImage(
  1. ImageProvider<Object> image
)

Convert ImageProvider to ui.Image e.g. TensorImageUtils.imageProviderToImage(const AssetImage('assets/images/image.png'))

Implementation

static Future<ui.Image> imageProviderToImage(ImageProvider image) {
  Completer<ui.Image> completer = Completer.sync();
  image.resolve(ImageConfiguration.empty).addListener(
      ImageStreamListener((ImageInfo image, bool synchronousCall) {
    if (!completer.isCompleted) completer.complete(image.image);
  }));
  return completer.future;
}