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

Serializes and deserializes Dart Url values to and from strings.

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

Serialization Rules

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

Deserialization Rules

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

Example

final adapter = UrlSerializationAdapter();

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

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

Notes

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

Constructors

UrlSerializationAdapter()
Creates a new UrlSerializationAdapter.

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) → Url?
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(Url 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<Url>
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