Convert class abstract
Backward-compatible static facade that mirrors the original ConvertObject API.
Use this class when you need stateless conversions that still honor the current ConvertConfig.effective settings.
Shared Behavior
mapKeyandlistIndexlet you select nested data before conversion.defaultValueshort-circuits failures for thetoXmethods.tryToXvariants never throw and returnnullordefaultValue.- Collection conversions decode JSON strings when possible and then convert elements using the same conversion rules.
For fluent, stateful conversion chains, prefer value.convert from
ConvertObjectExtension.
Constructors
- Convert()
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
-
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
Static Properties
- config → ConvertConfig
-
Returns the effective configuration for the current zone.
no setter
Static Methods
-
buildParsingInfo(
{required String method, dynamic object, dynamic mapKey, int? listIndex, String? format, String? locale, bool? autoDetectFormat, bool? useCurrentLocale, bool? utc, dynamic defaultValue, dynamic converter, Type? targetType, Map< String, dynamic> ? debugInfo}) → Map<String, dynamic> - Builds a diagnostic map describing a conversion attempt; mainly used by tests and error reporting.
-
configure(
ConvertConfig config) → ConvertConfig - Replaces the global configuration and returns the previous instance.
-
runScopedConfig<
T> (ConvertConfig overrides, T body()) → T -
Runs
bodywithoverridesapplied on top of the current effective config. -
string(
dynamic object, {dynamic mapKey, int? listIndex, String? defaultValue, ElementConverter< String> ? converter}) → String -
Converts
objectto String, optionally selectingmapKeyorlistIndexfirst. -
toBigInt(
dynamic object, {dynamic mapKey, int? listIndex, BigInt? defaultValue, ElementConverter< BigInt> ? converter}) → BigInt -
Converts
objectto BigInt, accepting BigInt, num, or numeric strings. -
toBool(
dynamic object, {dynamic mapKey, int? listIndex, bool? defaultValue, ElementConverter< bool> ? converter}) → bool -
Converts
objectto bool using BoolOptions from ConvertConfig. -
toDateTime(
dynamic object, {dynamic mapKey, int? listIndex, String? format, String? locale, bool autoDetectFormat = false, bool useCurrentLocale = false, bool utc = false, DateTime? defaultValue, ElementConverter< DateTime> ? converter}) → DateTime -
Converts
objectto a DateTime, respecting DateOptions defaults. -
toDouble(
dynamic object, {dynamic mapKey, int? listIndex, String? format, String? locale, double? defaultValue, ElementConverter< double> ? converter}) → double -
Converts
objectto double, supporting formatted numeric strings. -
toEnum<
T extends Enum> (dynamic object, {required T parser(dynamic), dynamic mapKey, int? listIndex, T? defaultValue, Map< String, dynamic> ? debugInfo}) → T -
Converts
objectto an enum using the suppliedparser. -
toInt(
dynamic object, {dynamic mapKey, int? listIndex, String? format, String? locale, int? defaultValue, ElementConverter< int> ? converter}) → int -
Converts
objectto int, applying optional locale-aware formatting. -
toList<
T> (dynamic object, {dynamic mapKey, int? listIndex, List< T> ? defaultValue, ElementConverter<T> ? elementConverter}) → List<T> -
Converts
objectto List, optionally mapping each element throughelementConverter. -
toMap<
K, V> (dynamic object, {dynamic mapKey, int? listIndex, Map< K, V> ? defaultValue, ElementConverter<K> ? keyConverter, ElementConverter<V> ? valueConverter}) → Map<K, V> -
Converts
objectto a strongly-typed Map, optionally transforming keys and values withkeyConverterandvalueConverter. -
toNum(
dynamic object, {dynamic mapKey, int? listIndex, String? format, String? locale, num? defaultValue, ElementConverter< num> ? converter}) → num -
Converts
objectto num, honoring NumberOptions defaults. -
toSet<
T> (dynamic object, {dynamic mapKey, int? listIndex, Set< T> ? defaultValue, ElementConverter<T> ? elementConverter}) → Set<T> -
Converts
objectto Set, applyingelementConverterto each entry. -
toType<
T> (dynamic object) → T -
Converts
objectto the requested typeT. -
toUri(
dynamic object, {dynamic mapKey, int? listIndex, Uri? defaultValue, ElementConverter< Uri> ? converter}) → Uri -
Converts
objectto Uri, honoring UriOptions from ConvertConfig. -
tryToBigInt(
dynamic object, {dynamic mapKey, int? listIndex, BigInt? defaultValue, ElementConverter< BigInt> ? converter}) → BigInt? -
Converts
objectto BigInt without throwing. -
tryToBool(
dynamic object, {dynamic mapKey, int? listIndex, bool? defaultValue, ElementConverter< bool> ? converter}) → bool? -
Converts
objectto bool without throwing. -
tryToDateTime(
dynamic object, {dynamic mapKey, int? listIndex, String? format, String? locale, bool autoDetectFormat = false, bool useCurrentLocale = false, bool utc = false, DateTime? defaultValue, ElementConverter< DateTime> ? converter}) → DateTime? - Like toDateTime but never throws.
-
tryToDouble(
dynamic object, {dynamic mapKey, int? listIndex, String? format, String? locale, double? defaultValue, ElementConverter< double> ? converter}) → double? -
Converts
objectto double without throwing. -
tryToEnum<
T extends Enum> (dynamic object, {required T parser(dynamic), dynamic mapKey, int? listIndex, T? defaultValue, Map< String, dynamic> ? debugInfo}) → T? -
Converts
objectto an enum usingparserwithout throwing. -
tryToInt(
dynamic object, {dynamic mapKey, String? format, String? locale, int? listIndex, int? defaultValue, ElementConverter< int> ? converter}) → int? -
Converts
objectto int without throwing. -
tryToList<
T> (dynamic object, {dynamic mapKey, int? listIndex, List< T> ? defaultValue, ElementConverter<T> ? elementConverter}) → List<T> ? -
Converts
objectto List without throwing. -
tryToMap<
K, V> (dynamic object, {dynamic mapKey, int? listIndex, Map< K, V> ? defaultValue, ElementConverter<K> ? keyConverter, ElementConverter<V> ? valueConverter}) → Map<K, V> ? -
Converts
objectto Map without throwing. -
tryToNum(
dynamic object, {dynamic mapKey, String? format, String? locale, int? listIndex, num? defaultValue, ElementConverter< num> ? converter}) → num? -
Converts
objectto num without throwing. -
tryToSet<
T> (dynamic object, {dynamic mapKey, int? listIndex, Set< T> ? defaultValue, ElementConverter<T> ? elementConverter}) → Set<T> ? -
Converts
objectto Set without throwing. -
tryToString(
dynamic object, {dynamic mapKey, int? listIndex, String? defaultValue, ElementConverter< String> ? converter}) → String? -
Converts
objectto String without throwing. -
tryToType<
T> (dynamic object) → T? -
Converts
objectto typeTwithout throwing. -
tryToUri(
dynamic object, {dynamic mapKey, int? listIndex, Uri? defaultValue, ElementConverter< Uri> ? converter}) → Uri? -
Converts
objectto Uri without throwing. -
updateConfig(
ConvertConfig updater(ConvertConfig current)) → void -
Updates the global configuration using
updater.