afterSerialize method

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

Implementation

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

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

  if (object is! Map<String, dynamic>) {
    throw StateError('HeaderPlugin can only be applied to Map<String, dynamic>. '
        'Please ensure the StandardJsonPlugin is applied and run before.');
  }

  final content = object['content'];
  return const HeaderEncoder().convert(content);
}