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
}
- Implementers
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
sourceType
can be converted totargetType
. -
convert<
T> (Object? source, Class< T> targetType, [String? qualifiedName]) β T? -
Converts the given
source
object to the specifiedtargetType
. -
convertTo<
T> (Object? source, Class targetType, [Class? sourceType]) β Object? -
Converts the
source
object from a knownsourceType
to atargetType
using full type metadata viaClass
. -
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