DefaultConversionService class
A specialization of SimpleConversionService configured by default with converters appropriate for most environments.
Designed for direct instantiation but also exposes the static addDefaultConverters utility method for ad-hoc use against any ConverterRegistry instance.
Example:
final service = DefaultConversionService();
final result = service.convert('123', Class.forType(int));
print(result); // 123
- Inheritance
-
- Object
- SimpleConversionService
- DefaultConversionService
Constructors
- DefaultConversionService([ProtectionDomain? protectionDomain])
- Create a new DefaultConversionService with the set of default converters.
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
-
addConverter<
S, T> (Converter< S, T> converter, {Class<S> ? sourceType, Class<T> ? targetType}) → void -
Registers a simple Converter from one specific source type to one target type.
inherited
-
addConverterFactory(
ConverterFactory factory) → void -
Registers a ConverterFactory that can produce Converter instances for a target type.
inherited
-
addNullSourceConverter(
GenericNullConverter converter) → void -
Adds a new GenericNullConverter to the list of registered converters.
inherited
-
addPairedConverter(
PairedConverter converter) → void -
Registers a PairedConverter capable of converting between multiple types.
inherited
-
addUriValidator(
UriValidator validator) → void -
Adds a new
UriValidator
to the list of registered validators.inherited -
canBypassConvert(
Class? sourceType, Class targetType) → bool -
Return whether conversion between the source type and the target type can be bypassed.
More precisely, this method will return true if objects of sourceType can be
converted to the target type by returning the source object unchanged.
inherited
-
canConvert(
Class? sourceType, Class targetType) → bool -
Determines whether objects of
sourceType
can be converted totargetType
.inherited -
convert<
T> (Object? source, Class< T> targetType, [String? qualifiedName]) → T? -
Converts the given
source
object to the specifiedtargetType
.inherited -
convertTo<
T> (Object? source, Class targetType, [Class? sourceType]) → Object? -
Converts the
source
object from a knownsourceType
to atargetType
using full type metadata viaClass
.inherited -
getUriValidators(
) → List< UriValidator> -
Returns a list of registered
UriValidator
instances.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
Class sourceType, Class targetType) → void -
Removes a registered converter between the specified source and target types.
inherited
-
removeNullSourceConverter(
GenericNullConverter converter) → void -
Removes a registered GenericNullConverter.
inherited
-
removeUriValidator(
UriValidator validator) → void -
Removes a registered
UriValidator
.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- defaultZone ↔ ZoneId
-
getter/setter pair
Static Methods
-
addCollectionConverters(
ConverterRegistry registry) → void - Add common collection converters.
-
addDefaultConverters(
ConverterRegistry registry) → void - Add converters appropriate for most environments.
-
addJetLeafConverters(
ConverterRegistry registry) → void - Add JetLeaf-specific converters.
-
addMapConverters(
ConverterRegistry registry) → void - Add map-related converters.
-
addOtherDartConverters(
ConverterRegistry registry) → void - Add other Dart built-in type converters.
-
addScalarConverters(
ConverterRegistry registry) → void -
addTimeConverters(
ConverterRegistry registry) → void - Add time-related converters.
- Return a shared default ConversionService instance, lazily building it once needed.