ConversionService class abstract
A strategy interface for type conversion.
Implementations of this interface are responsible for converting values between
different types, such as from String to int, List<String> to Set<int>, or
custom object mappings.
Typically used in configuration binding, message deserialization, and property resolution pipelines.
🔧 Example Usage:
final service = DefaultConversionService();
if (service.canConvert<String, int>(Class<String>(), Class<int>())) {
final value = service.convert<int>('42', Class<int>());
print(value + 1); // 43
}
Constructors
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
-
canConvert(
Class? sourceType, Class targetType) → bool -
Determines whether objects of
sourceTypecan be converted totargetType. -
convert<
T> (Object? source, Class< T> targetType, [String? qualifiedName]) → T? -
Converts the given
sourceobject to the specifiedtargetType. -
convertTo<
T> (Object? source, Class targetType, [Class? sourceType]) → Object? -
Converts the
sourceobject from a knownsourceTypeto atargetTypeusing full type metadata via Class. -
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