createImageElementFromFile function

Future<ImageElement> createImageElementFromFile(
  1. File file
)

Creates an image from a file.

Implementation

Future<ImageElement> createImageElementFromFile(File file) {
  var reader = FileReader();

  var completer = Completer<ImageElement>();

  reader.onLoadEnd.listen((e) {
    completer.complete(createImageElementFromBase64(reader.result as String?));
  });

  reader.readAsDataUrl(file);

  return completer.future;
}