beforeDeserialize method

  1. @override
Object? beforeDeserialize(
  1. Object? object,
  2. FullType specifiedType
)
override

Implementation

@override
Object? beforeDeserialize(Object? object, FullType specifiedType) {
  if (specifiedType.root != ContentString) {
    return object;
  }

  if (object == null) {
    return object;
  }

  if (object is! String) {
    throw StateError('The serialized ContentString must be of type String. '
        'Please ensure the StandardJsonPlugin is applied and run before.');
  }

  final content = jsonDecode(object);

  return ['content', content];
}