Skip to content

Instantly share code, notes, and snippets.

@fariswd
Last active April 14, 2019 03:08
Show Gist options
  • Save fariswd/38818429aea224b28e08ca4782a26beb to your computer and use it in GitHub Desktop.
Save fariswd/38818429aea224b28e08ca4782a26beb to your computer and use it in GitHub Desktop.
Dart Imutable map
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