deserialize method

  1. @override
Shape deserialize(
  1. Serializers serializers,
  2. Iterable<Object?> serialized, {
  3. FullType specifiedType = FullType.unspecified,
})
override

Deserializes serialized.

serialized is an Iterable that may contain booleans, integers, doubles, Strings and/or Iterables.

Use serializers as needed for nested deserialization. Information about the type being deserialized is provided in specifiedType.

Implementation

@override
Shape deserialize(
  Serializers serializers,
  Iterable<Object?> serialized, {
  FullType specifiedType = FullType.unspecified,
}) {
  final iterator = serialized.iterator;
  while (iterator.moveNext()) {
    final key = iterator.current as String;
    iterator.moveNext();
    final value = iterator.current;
    if (key == 'type') {
      final type = ShapeType.deserialize(value as String);
      return serializers.deserialize(
        serialized,
        specifiedType: FullType(type.type),
      ) as Shape;
    }
  }
  throw ArgumentError('Unknown shape type');
}