Last active
April 14, 2019 03:08
-
-
Save fariswd/38818429aea224b28e08ca4782a26beb to your computer and use it in GitHub Desktop.
Dart Imutable map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
Map groceries = { | |
'fruit': ['apple', 'orange', 'grapes'], | |
'vegetable': [], | |
}; | |
Map addVegetable = Map() | |
..addAll(groceries) | |
..putIfAbsent('vegetable', () => ['carrot', 'tomato']) | |
..update('vegetable', (_) => ['carrot']); | |
print(addVegetable); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment