load static method

Future<Image> load(
  1. Uint8List imgBytes, {
  2. dynamic onDone(
    1. Image
    )?,
})

Implementation

static Future<ui.Image> load(Uint8List imgBytes,
    {final Function(ui.Image)? onDone}) {
  // Create completer for later completion
  final Completer<ui.Image> completer = Completer();

  // Decode image from bytes, will run async and call callback later
  ui.decodeImageFromList(imgBytes, (ui.Image img) {
    // Report done if wished
    if (onDone != null) {
      onDone(img);
    }

    // Complete to return image future
    completer.complete(img);
  });

  return completer.future;
}