Reputation: 17
How do I add a new key value to an existing map? I've searched but nowhere seem to answer for my example. My map looks like this:
myMap = {A: {b:3}}
I'm simply trying to add key values into 'A' so it looks like this:
{A: {b:3, c:3}}
Hope that makes sense!
Upvotes: 0
Views: 681
Reputation: 9734
void main() {
var myMap = {'A': {'b':3}};
myMap['A']!['c'] = 3;
print(myMap);
}
Upvotes: 2
Reputation: 1663
Assuming you started with:
var myMap = {'A': {'b': 3}};
You can update like this:
myMap['A'] = {
'b': 3,
'c': 3,
};
Upvotes: 1