MapConverter class

Converts arbitrary values into map objects using extended conversion rules:

  • Objects: property names as keys, property values as values
  • Arrays: element indexes as keys, elements as values

Example

var value1 = MapConverted.toNullableMap('ABC'); // Result: null
var value2 = MapConverted.toNullableMap({ 'key': 123 }); // Result: { 'key': 123 }
var value3 = MapConverted.toNullableMap([1,2,3]); // Result: { '0': 1, '1': 2, '2': 3 }

Constructors

MapConverter()

Properties

hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited

Static Methods

toMap(dynamic value) → Map<String, dynamic>
Converts value into map object or returns empty map when conversion is not possible [...]
toMapWithDefault(dynamic value, Map<String, dynamic> defaultValue) → Map<String, dynamic>
Converts value into map object or returns default when conversion is not possible [...]
toNullableMap(dynamic value) → Map<String, dynamic>
Converts value into map object or returns null when conversion is not possible. [...]