how to add data in map dart code example
Example 1: flutter create new map
Map<String, int> map1 = {'zero': 0, 'one': 1, 'two': 2};
Map map2 = {'zero': 0, 'I': 'one', 10: 'X'};
var map3 = {'zero': 0, 'I': 'one', 10: 'X'};
Example 2: dart object to map
class Human {
String name;
int age;
Map<String, dynamic> toMap() {
return {
'name': name,
'age': age,
};
}
}