beforeDeserialize method

  1. @override
Object? beforeDeserialize(
  1. Object? object,
  2. 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];
}