A general-purpose converter that can convert between multiple source–target type pairs.
This interface allows conversion logic to be shared across multiple type mappings, and optionally exposes the set of convertible type pairs.
🔧 Example:
class MyConverter implements PairedConverter {
@override
Set<ConvertiblePair> getConvertibleTypes() => {
ConvertiblePair(Class<String>(), Class<int>())
};
@override
Object? convert(Object? source, Class sourceType, Class targetType) {
if (source is String && targetType.getType() == int) {
return int.tryParse(source);
}
return null;
}
}
- 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.
-
getConvertibleTypes(
) → Set< ConvertiblePair> ? - A general-purpose converter that can convert between multiple source–target type pairs.
-
getPackageName(
) → String -
Represents an abstraction for identifying the package that an object,
resource, or service belongs to.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited