decode static method

List<Change> decode(
  1. Uint8List bytes
)

Decode a changeset blob into its Change list.

Implementation

static List<Change> decode(Uint8List bytes) {
  final doc = jsonDecode(utf8.decode(bytes)) as Map<String, Object?>;
  if (doc['__ddbs_changeset__'] != 1) {
    throw FormatException('not a dart_db_server changeset');
  }
  return [
    for (final c in (doc['changes'] as List).cast<Map<String, Object?>>())
      Change.fromJson(c)
  ];
}