Created
October 29, 2020 08:11
-
-
Save sodogan/f108d8176f637ff3ad3b5e4f5e37f5d1 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
Dart samples: | |
To copy a list or map | |
use: | |
var myList = [...myBaseList]; | |
var myMap = {...myBaseMap}; | |
*/ | |
void main(List<String> args) { | |
Map<String, String> myBaseMap = <String, String>{} | |
..addAll({'Turkey': 'Istanbul'}) | |
..putIfAbsent('Australia', () => 'Canberra') | |
..putIfAbsent('Australia', () => 'Canberra'); | |
print(myBaseMap); | |
//how do you define list of Maps? | |
List<Map<String, List<String>>> interests = [ | |
{ | |
'solen': ['dance', 'swim'] | |
} | |
]..add({ | |
'eren': ['dance', 'swim'] | |
}); | |
var hisInterests = {...interests}; | |
print(hisInterests); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment