capture function

Future<Uint8List> capture()

Implementation

Future<Uint8List> capture() {
  final boundary =
      // ignore: cast_nullable_to_non_nullable
      photoKey.currentContext?.findRenderObject() as RenderRepaintBoundary;
  /* if (boundary.debugNeedsPaint) {
    unawaited(delayed(capture, 1000));
    return Future.value(Uint8List(0));
  }*/

  return Task(boundary.toImage)
      .flatMap(
        (final img) =>
            Task(() => img.toByteData(format: ui.ImageByteFormat.png)),
      )
      .map((final data) => data?.buffer.asUint8List() ?? Uint8List(0))
      .run();
}