initMemoryDecoder method

  1. @override
Future<AvifInfo> initMemoryDecoder({
  1. required String key,
  2. required Uint8List avifBytes,
})
override

Implementation

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

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

    completer.complete(info);
  };

  flutterAvifFFI.init_memory_decoder(
    port.sendPort.nativePort,
    nativeRequest[0],
    nativeRequest[1],
  );
  malloc.free(nativeRequest[0]);

  return completer.future;
}