UriSerializationAdapter<G extends Generator, P extends Parser, DC extends DeserializationContext<Parser>, SC extends SerializationContext<Generator>> class final

Serializes and deserializes Dart Uri values to and from strings.

The UriSerializationAdapter provides a unified adapter for handling Uri objects in both serialization and deserialization, supporting JSON and generic generators/parsers.

Serialization Rules

  • Converts the Uri to its string representation using toString().
  • Writes the value using generator.writeString().

Deserialization Rules

  • Accepts string values and converts them to Uri using Uri.parse().
  • Uses the context's ConversionService if available for type conversion.
  • Throws FormatException if the input is not a valid string.

Example

final adapter = UriSerializationAdapter();

final uri = Uri.parse("https://example.com/path");
adapter.serialize(uri, generator, context);
// JSON output: "https://example.com/path"

final parsed = adapter.deserialize(parser, context, Class.forType(Uri));
// parsed is a Uri instance

Notes

  • This adapter expects valid URI strings; malformed strings will result in a runtime exception.
Implemented types
Annotations
  • @Generic.new(UriSerializationAdapter)

Constructors

UriSerializationAdapter()
Creates a new UriSerializationAdapter.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

canDeserialize(Class type) bool
Returns whether the given type can be deserialized by the system.
override
canSerialize(Class type) bool
Returns whether the given type can be serialized by the system.
override
deserialize(P parser, DC ctxt, Class toClass) Uri?
Deserializes an object of type T using the given P and DeserializationContext.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
serialize(Uri value, G generator, SC serializer) → void
Serializes an object of type T into an object using the provided Generator and SerializationContext.
override
supports(DeserializationContext<Parser> context) bool
Determines whether this deserializer supports the given deserialization context.
inherited
supportsContext(SerializationContext<Generator> context) bool
Determines whether this serializer supports the given serialization context.
inherited
toClass() → Class<Uri>
Provides a contract for types capable of exposing their associated runtime Class metadata representation within the JetLeaf reflection system.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited