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.
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 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.