decode method

RitoDisplayList decode(
  1. Uint8List bytes
)

Implementation

RitoDisplayList decode(Uint8List bytes) {
  if (bytes.length > ritoMaxWireBytes) {
    throw const FormatException('RITODL1 exceeds the byte limit.');
  }
  final reader = RitoBinaryReader(bytes);
  reader.expectMagic(_magic, 'display list magic');
  final version = reader.uint32('display list version');
  if (version != formatVersion) {
    reader.fail('unsupported display list version: $version');
  }
  final count = reader.count('display command count');
  final commands = <RitoCommand>[];
  for (var index = 0; index < count; index += 1) {
    commands.add(_command(reader));
  }
  reader.finish('display list');
  return RitoDisplayList(formatVersion: version, commands: commands);
}