beforeDeserialize method
Object?
beforeDeserialize(
- Object? object,
- FullType specifiedType
)
override
Implementation
@override
Object? beforeDeserialize(Object? object, FullType specifiedType) {
if (specifiedType.root != Header) {
return object;
}
if (object == null) {
return object;
}
if (object is! String) {
throw StateError('The serialized Header must be of type String. '
'Please ensure the StandardJsonPlugin is applied and run before.');
}
final elementType = specifiedType.parameters.isEmpty ? FullType.unspecified : specifiedType.parameters[0];
final content = HeaderDecoder(specifiedType: elementType).convert(object);
return ['content', content];
}