decodeSingleFrameImage method

  1. @override
Future<Frame> decodeSingleFrameImage({
  1. required Uint8List avifBytes,
})
override

Implementation

@override
Future<Frame> decodeSingleFrameImage({required Uint8List avifBytes}) {
  final request = KeyRequest(
    key: "",
    data: avifBytes,
  ).writeToBuffer();
  final nativeRequest = toPointer(request);

  final completer = Completer<Frame>();
  final port = RawReceivePort();
  port.handler = (response) {
    port.close();

    final frame = Frame.fromBuffer(response);
    completer.complete(frame);
  };

  flutterAvifFFI.decode_single_frame_image(
    port.sendPort.nativePort,
    nativeRequest[0],
    nativeRequest[1],
  );

  malloc.free(nativeRequest[0]);

  return completer.future;
}