PairedConditionalConverter class abstract

A bridge interface combining PairedConverter and ConditionalConverter.

Use this when writing a paired converter that should only match under specific conditions.


đź”§ Example:

class ConditionalUriConverter extends ConditionalPairedConverter {
  @override
  Set<ConvertiblePair> getConvertibleTypes() => {
    ConvertiblePair(Class<String>(), Class<Uri>())
  };

  @override
  bool matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
    return sourceType.type == String && targetType.type == Uri;
  }

  @override
  Object? convert(Object? source, TypeDescriptor sourceType, TypeDescriptor targetType) {
    return Uri.tryParse(source as String);
  }
}
Inheritance
Implemented types
Implementers

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

convert<T>(Object? source, Class sourceType, Class targetType) → Object?
A general-purpose converter that can convert between multiple source–target type pairs.
inherited
getConvertibleTypes() → Set<ConvertiblePair>?
A general-purpose converter that can convert between multiple source–target type pairs.
inherited
getPackageName() → String
Represents an abstraction for identifying the package that an object, resource, or service belongs to.
inherited
matches(Class sourceType, Class targetType) → bool
A contract for a converter that only matches under certain conditions.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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