MapConversionX<K, V> extension
Type conversion helpers for non-nullable Map instances.
Provides key-based value extraction with automatic type conversion.
Each method looks up the value for key (with optional fallback to
alternativeKeys) and converts it to the target type.
Example
final json = {'name': 'Alice', 'age': '25', 'active': 'true'};
final name = json.getString('name'); // 'Alice'
final age = json.getInt('age'); // 25
final active = json.getBool('active'); // true
Alternative Keys
When APIs vary in naming conventions, use alternativeKeys for resilience:
final id = json.getInt('id', alternativeKeys: ['ID', '_id', 'userId']);
Nested Navigation
For complex structures, use innerKey and innerListIndex:
final city = json.getString('address', innerKey: 'city');
See also: NullableMapConversionX for nullable-safe tryGetX variants.
- on
-
- Map<
K, V>
- Map<
Properties
-
keysList
→ List<
K> -
Available on Map<
Returns a list containing all the keys in the map.K, V> , provided by the MapConversionX extensionno setter -
keysSet
→ Set<
K> -
Available on Map<
Returns a set containing all the keys in the map.K, V> , provided by the MapConversionX extensionno setter -
valuesList
→ List<
V> -
Available on Map<
Returns a list containing all the values in the map.K, V> , provided by the MapConversionX extensionno setter -
valuesSet
→ Set<
V> -
Available on Map<
Returns a set containing all the values in the map.K, V> , provided by the MapConversionX extensionno setter
Methods
-
getBigInt(
K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, BigInt? defaultValue, ElementConverter<BigInt> ? converter}) → BigInt -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to BigInt. -
getBool(
K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, bool? defaultValue, ElementConverter<bool> ? converter}) → bool -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to bool. -
getDateTime(
K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, String? format, String? locale, bool autoDetectFormat = false, bool useCurrentLocale = false, bool utc = false, DateTime? defaultValue, ElementConverter<DateTime> ? converter}) → DateTime -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to DateTime. -
getDouble(
K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, double? defaultValue, String? format, String? locale, ElementConverter<double> ? converter}) → double -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to double. -
getEnum<
T extends Enum> (K key, {required T parser(dynamic), List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, T? defaultValue, Map<String, dynamic> ? debugInfo}) → T -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to an enum usingparser. -
getInt(
K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, int? defaultValue, String? format, String? locale, ElementConverter<int> ? converter}) → int -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to int. -
getList<
T> (K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, List<T> ? defaultValue, ElementConverter<T> ? elementConverter}) → List<T> -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to a List ofT. -
getMap<
K2, V2> (K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, Map<K2, V2> ? defaultValue, ElementConverter<K2> ? keyConverter, ElementConverter<V2> ? valueConverter}) → Map<K2, V2> -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to a Map ofK2toV2. -
getNum(
K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, num? defaultValue, String? format, String? locale, ElementConverter<num> ? converter}) → num -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to num. -
getSet<
T> (K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, Set<T> ? defaultValue, ElementConverter<T> ? elementConverter}) → Set<T> -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to a Set ofT. -
getString(
K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, String? defaultValue, ElementConverter<String> ? converter}) → String -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to String. -
getUri(
K key, {List< K> ? alternativeKeys, dynamic innerKey, int? innerListIndex, Uri? defaultValue, ElementConverter<Uri> ? converter}) → Uri -
Available on Map<
Converts the value atK, V> , provided by the MapConversionX extensionkey(oralternativeKeys) to Uri. -
parse<
T, K2, V2> (K key, T converter(Map< K2, V2> json)) → T -
Available on Map<
Parses the nested map atK, V> , provided by the MapConversionX extensionkeyusing the providedconverter. -
tryParse<
T, K2, V2> (K key, T converter(Map< K2, V2> json)) → T? -
Available on Map<
Tries to parse the nested map atK, V> , provided by the MapConversionX extensionkeyusing the providedconverter.