getMap method

Map<String, Map> getMap()

Converts the map of models to a map of maps.

Example:

final models = {
  '1': Person(id: '1', name: 'John', age: 30),
  '2': Person(id: '2', name: 'Doe', age: 25),
};
final maps = models.map;
print(maps); // {'1': {'id': '1', 'name': 'John', 'age': 30}, '2': {'id': '2', 'name': 'Doe', 'age': 25}}

Output:

{'1': {'id': '1', 'name': 'John', 'age': 30}, '2': {'id': '2', 'name': 'Doe', 'age': 25}}

Implementation

Map<String, Map> getMap() => {
  for (final entry in entries) entry.key: entry.value.map,
};