fromJson<DataType extends Object> static method
- Map<
String, Object?> json, - StateValueDecoder<
DataType> decodeData
Decodes a tagged-state image.
Implementation
static TaggedStateTableImage<DataType> fromJson<DataType extends Object>(
Map<String, Object?> json,
StateValueDecoder<DataType> decodeData,
) {
_validateHeader(json, kind, version);
final capacity = _positiveInt(json, 'capacity');
final decoded = List<DataType?>.filled(capacity, null);
for (final encoded in _entryList(json)) {
final entry = _entryMap(encoded);
final index = _entryIndex(entry, capacity);
if (decoded[index] != null) {
throw FormatException('Duplicate state entry index $index.');
}
decoded[index] = decodeData(entry['data']);
}
return TaggedStateTableImage(decoded);
}