parse method
T
parse(
- Serialized serialized
Parse a value from json, and populate this JsonKey with the parsed value.
@pre The JsonKey must be in the _ParserState state.
Implementation
T parse(Serialized serialized) => switch (_state) {
_FullyPopulatedState(value: final value) ||
_PopulatedState(value: final value) =>
throw StateError(
'Tried to parse $key with $serialized, but $key is already '
'populated with value: $value.'),
_ParserState(parser: final parser) => () {
final val = parser(serialized);
_state = _FullyPopulatedState(val, serialized);
return val;
}()
};