MapExtension extension

on

Methods

isNull(String name) bool
Returns true if this object has no mapping for {@code name} or if it has a mapping whose value is {@link #NULL}.
mapNotNull<T>(T transform(String, dynamic)) List<T>
Returns a list containing the results of applying the given transform function to each element in the original Map. If the tranform returns null, it is not included in the output list.
opt(String name) → dynamic
Returns the value mapped by {@code name}, or null if no such mapping exists.
optBoolean(String name, {bool fallback = false}) bool
Returns the value mapped by {@code name} if it exists and is a boolean or can be coerced to a boolean, or {@code fallback} otherwise.
optDouble(String name, {double fallback = double.nan}) double
Returns the value mapped by {@code name} if it exists and is a double or can be coerced to a double, or {@code fallback} otherwise.
optInt(String name, {int fallback = 0}) int
Returns the value mapped by {@code name} if it exists and is an int or can be coerced to an int, or {@code fallback} otherwise.
optJSONArray(String name) List?
Returns the value mapped by {@code name} if it exists and is a {@code JSONArray}, or null otherwise.
optJSONObject(String name) Map<String, dynamic>?
Returns the value mapped by {@code name} if it exists and is a {@code Map}, or null otherwise.
optNullableBoolean(String name, {bool remove = false}) bool?
Returns the value mapped by name if it exists, coercing it if necessary, or null if no such mapping exists. If remove is true, then the mapping will be removed from the Map.
optNullableDouble(String name, {bool remove = false}) double?
Returns the value mapped by name if it exists, coercing it if necessary, or null if no such mapping exists. If remove is true, then the mapping will be removed from the Map.
optNullableInt(String name, {bool remove = false}) int?
Returns the value mapped by name if it exists, coercing it if necessary, or null if no such mapping exists. If remove is true, then the mapping will be removed from the Map.
optNullableString(String name, {bool remove = false}) String?
Returns the value mapped by name if it exists, coercing it if necessary, or null if no such mapping exists. If remove is true, then the mapping will be removed from the Map.
optPositiveDouble(String name, {double fallback = -1.0, bool remove = false}) double?
Returns the value mapped by name if it exists and is a positive double or can be coerced to a positive double, or fallback otherwise. If remove is true, then the mapping will be removed from the Map.
optPositiveInt(String name, {int fallback = -1, bool remove = false}) int?
Returns the value mapped by name if it exists and is a positive integer or can be coerced to a positive integer, or fallback otherwise. If remove is true, then the mapping will be removed from the Map.
optString(String name, {String fallback = ""}) String
Returns the value mapped by {@code name} if it exists, coercing it if necessary, or {@code fallback} if no such mapping exists.
optStringsFromArrayOrSingle(String name, {bool remove = false}) List<String>
Returns the value mapped by name if it exists and is either a List of String or a single String value, or an empty list otherwise. If remove is true, then the mapping will be removed from the Map.
put(String name, dynamic object) → void
putIterableIfNotEmpty(String name, Iterable? collection) → void
Maps name to collection after wrapping it in a List, clobbering any existing name/value mapping with the same name. If the collection is empty, any existing mapping for name is removed. If the objects in collection are JSONable, then they are converted to Map first.
putJSONableIfNotEmpty(String name, JSONable? jsonable) → void
Maps name to jsonable after converting it to a Map, clobbering any existing name/value mapping with the same name. If the Map argument is empty, any existing mapping for name is removed.
putMapIfNotEmpty(String name, Map<String, dynamic> map) → void
Maps name to map after wrapping it in a Map, clobbering any existing name/value mapping with the same name. If the map is empty, any existing mapping for name is removed. If the objects in map are JSONable, then they are converted to Map first.
putObjectIfNotEmpty(String name, Map<String, dynamic>? jsonObject) → void
Maps name to jsonObject, clobbering any existing name/value mapping with the same name. If the Map is empty, any existing mapping for name is removed.
putOpt(String? name, Object? value) → void