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
Urito its string representation usingtoString(). - Writes the value using
generator.writeString().
Deserialization Rules
- Accepts string values and converts them to
UriusingUri.parse(). - Uses the context's
ConversionServiceif 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
-
- ObjectSerializable
- ObjectSerializer<
T, G, SC> - ObjectDeserializer<
T, P, DC>
- 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
typecan be deserialized by the system.override -
canSerialize(
Class type) → bool -
Returns whether the given
typecan be serialized by the system.override -
deserialize(
P parser, DC ctxt, Class toClass) → Uri? -
Deserializes an object of type
Tusing the givenPand 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
Tinto 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
Classmetadata representation within the JetLeaf reflection system. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited