decode method

  1. @override
Uri decode(
  1. Decoder decoder
)
override

Decodes a value of type T using the decoder.

The implementation should first use Decoder.whatsNext to determine the type of the encoded data. Then it should use one of the Decoders .decode...() methods to decode into its target type. If the returned DecodingType is not supported, the implementation can use Decoder.expect to throw a detailed error.

Implementation

@override
Uri decode(Decoder decoder) {
  return switch (decoder.whatsNext()) {
    DecodingType.string || DecodingType.unknown => Uri.parse(decoder.decodeString()),
    DecodingType<Uri>() => decoder.decodeObject<Uri>(),
    _ => decoder.expect('string or custom uri'),
  };
}