convert_object library

A comprehensive type conversion library for Dart.

This library provides a fluent API for converting between different types with extensive support for collections, custom converters, and safe conversions.

Classes

BoolOptions
Options that control boolean parsing.
ConversionResult<T>
Represents the outcome of a conversion, capturing either a value or error.
Convert
Backward-compatible static facade that mirrors the original ConvertObject API.
ConvertConfig
A single global instance is used by default. You can:
Converter
Fluent wrapper that offers composable access to conversion helpers.
DateOptions
Options that control date/time parsing.
EnumParsers
Helpers for building resilient enum parsing callbacks.
JsonOptions
Options controlling how values are normalized into JSON-safe forms.
NumberOptions
Options that control numeric parsing.
TypeRegistry
Registry of custom parsers used by Convert.toType / Convert.tryToType.
UriOptions
Options that control URI parsing and coercion.

Enums

DateTimeStrategy
Strategy for encoding DateTime values.
DurationStrategy
Strategy for encoding Duration values.
NonFiniteDoubleStrategy
Strategy for non-finite doubles (NaN, Infinity, -Infinity).

Extensions

BoolParsingX on Object?
Adds boolean parsing helpers to dynamic values.
ConvertObjectExtension on Object?
Adds a convert getter that exposes the fluent Converter API.
DateParsingTextX on String
Extension methods for parsing String values into DateTime instances.
EnumValuesParsing on List<T>
Convenience accessors for creating enum parsing callbacks from a list.
IterableConversionX on Iterable<E>
Conversion helpers for non-null Iterable collections.
JsonAnyX on Object?
JsonIterableX on Iterable<T>
JsonMapX on Map<K, V>
LetExtension on T
Kotlin-style let helper for non-nullable types.
LetExtensionNullable on T?
Kotlin-style let helpers for nullable types.
MapConversionX on Map<K, V>
Conversion helpers for non-nullable maps.
NullableIterableConversionX on Iterable<E>?
Conversion helpers for nullable Iterable collections.
NullableMapConversionX on Map<K, V>?
Conversion helpers for nullable maps.
NumParsingTextX on String
Extension methods for parsing numeric strings with lenient formatting.
RomanNumeralIntX on num
Roman numeral helpers for integers.
RomanNumeralNullableStringX on String?
Roman numeral helpers for nullable strings.
RomanNumeralStringX on String
Roman numeral helpers for strings.
SetConvertToX on Set<E>?
Converts nullable sets into a Set of a different type.
TextJsonX on String
Adds JSON decoding helpers to String.
UriParsingX on String
Extension methods for validating and converting URI-like strings.

Constants

romanNumerals → const Map<int, String>
A map of integers to Roman numeral representations.

Functions

convertToBigInt(dynamic object, {Object? mapKey, int? listIndex, BigInt? defaultValue, BigInt converter(Object?)?}) BigInt
Top-level convenience alias for Convert.toBigInt.
convertToBool(dynamic object, {Object? mapKey, int? listIndex, bool? defaultValue, bool converter(Object?)?}) bool
Top-level convenience alias for Convert.toBool.
convertToDateTime(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, bool autoDetectFormat = false, bool useCurrentLocale = false, bool utc = false, DateTime? defaultValue, DateTime converter(Object?)?}) DateTime
Top-level convenience alias for Convert.toDateTime.
convertToDouble(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, double? defaultValue, double converter(Object?)?}) double
Top-level convenience alias for Convert.toDouble.
convertToInt(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, int? defaultValue, int converter(Object?)?}) int
Top-level convenience alias for Convert.toInt.
convertToList<T>(dynamic object, {Object? mapKey, int? listIndex, List<T>? defaultValue, T elementConverter(Object?)?}) List<T>
Top-level convenience alias for Convert.toList.
convertToMap<K, V>(dynamic object, {Object? mapKey, int? listIndex, Map<K, V>? defaultValue, K keyConverter(Object?)?, V valueConverter(Object?)?}) Map<K, V>
Top-level convenience alias for Convert.toMap.
convertToNum(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, num? defaultValue, num converter(Object?)?}) num
Top-level convenience alias for Convert.toNum.
convertToSet<T>(dynamic object, {Object? mapKey, int? listIndex, Set<T>? defaultValue, T elementConverter(Object?)?}) Set<T>
Top-level convenience alias for Convert.toSet.
convertToString(dynamic object, {Object? mapKey, int? listIndex, String? defaultValue, String converter(Object?)?}) String
Top-level convenience alias for Convert.string.
convertToType<T>(dynamic object) → T
Top-level convenience alias for Convert.toType.
convertToUri(dynamic object, {Object? mapKey, int? listIndex, Uri? defaultValue, Uri converter(Object?)?}) Uri
Top-level convenience alias for Convert.toUri.
intToRomanNumeral(int value) String
Converts an integer into a Roman numeral string.
jsonSafe(dynamic value, {JsonOptions options = const JsonOptions(), Object? toEncodable(dynamic object)?}) → dynamic
Returns a JSON-encodable form of value, honoring options.
romanNumeralToInt(String romanNumeral) int
Converts a Roman numeral string into an integer.
tryConvertToBigInt(dynamic object, {Object? mapKey, int? listIndex, BigInt? defaultValue, BigInt converter(Object?)?}) BigInt?
Top-level convenience alias for Convert.tryToBigInt.
tryConvertToBool(dynamic object, {Object? mapKey, int? listIndex, bool? defaultValue, bool converter(Object?)?}) bool?
Top-level convenience alias for Convert.tryToBool.
tryConvertToDateTime(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, bool autoDetectFormat = false, bool useCurrentLocale = false, bool utc = false, DateTime? defaultValue, DateTime converter(Object?)?}) DateTime?
Top-level convenience alias for Convert.tryToDateTime.
tryConvertToDouble(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, double? defaultValue, double converter(Object?)?}) double?
Top-level convenience alias for Convert.tryToDouble.
tryConvertToInt(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, int? defaultValue, int converter(Object?)?}) int?
Top-level convenience alias for Convert.tryToInt.
tryConvertToList<T>(dynamic object, {Object? mapKey, int? listIndex, List<T>? defaultValue, T elementConverter(Object?)?}) List<T>?
Top-level convenience alias for Convert.tryToList.
tryConvertToMap<K, V>(dynamic object, {Object? mapKey, int? listIndex, Map<K, V>? defaultValue, K keyConverter(Object?)?, V valueConverter(Object?)?}) Map<K, V>?
Top-level convenience alias for Convert.tryToMap.
tryConvertToNum(dynamic object, {Object? mapKey, int? listIndex, String? format, String? locale, num? defaultValue, num converter(Object?)?}) num?
Top-level convenience alias for Convert.tryToNum.
tryConvertToSet<T>(dynamic object, {Object? mapKey, int? listIndex, Set<T>? defaultValue, T elementConverter(Object?)?}) Set<T>?
Top-level convenience alias for Convert.tryToSet.
tryConvertToString(dynamic object, {Object? mapKey, int? listIndex, String? defaultValue, String converter(Object?)?}) String?
Top-level convenience alias for Convert.tryToString.
tryConvertToType<T>(dynamic object) → T?
Top-level convenience alias for Convert.tryToType.
tryConvertToUri(dynamic object, {Object? mapKey, int? listIndex, Uri? defaultValue, Uri converter(Object?)?}) Uri?
Top-level convenience alias for Convert.tryToUri.

Typedefs

DynamicConverter<T> = T Function(Object? value)
Signature for lazily transforming a stored value before conversion.
ElementConverter<T> = T Function(Object? element)
Signature for transforming a single element while converting collections.

Exceptions / Errors

ConversionException
Exception thrown when a conversion fails.