revToRml function

Uint8List? revToRml(
  1. Uint8List revBytes
)

Converts the bytes of a .rev file into the equivalent .rml markup document, with every payload embedded. Returns null when the bytes are not a readable .rev.

Implementation

Uint8List? revToRml(Uint8List revBytes) {
  if (revBytes.isEmpty) {
    return null;
  }
  final source = calloc<Uint8>(revBytes.length);
  final response = calloc<_RmlExportResponseStruct>();
  try {
    source.asTypedList(revBytes.length).setAll(0, revBytes);
    final ok = _revToRml(source, revBytes.length, response);
    if (!ok || response.ref.data == nullptr || response.ref.size <= 0) {
      return null;
    }
    // A view over native memory; copy it out before freeing.
    return Uint8List.fromList(
      response.ref.data.asTypedList(response.ref.size),
    );
  } finally {
    _freeRmlExport(response);
    calloc.free(response);
    calloc.free(source);
  }
}