jsonsToUint8Lists static method

List<Uint8List> jsonsToUint8Lists(
  1. Iterable<String> jsons
)

Implementation

static List<Uint8List> jsonsToUint8Lists(Iterable<String> jsons) {
  List<Uint8List> chunks = [];

  for (String json in jsons) {
    Utf8Encoder encoder = const Utf8Encoder();
    Uint8List bytes = encoder.convert(json);
    var size = bytes.length;

    if (size > maxJsonSize)
      throw PersistException("Size is $size but max is $maxJsonSize bytes.");

    chunks.add(Uint8List.fromList([size ~/ 256, size % 256]));
    chunks.add(bytes);
  }

  return chunks;
}