Skip to content

Instantly share code, notes, and snippets.

@k4zek4ge
Created October 21, 2019 09:00
Show Gist options
  • Save k4zek4ge/760dc01ce1b592e305ab55dcb7622908 to your computer and use it in GitHub Desktop.
Save k4zek4ge/760dc01ce1b592e305ab55dcb7622908 to your computer and use it in GitHub Desktop.
//=========================
//Use toSet and then toList
var ids = [1, 4, 4, 4, 5, 6, 6];
var distinctIds = ids.toSet().toList(); //[1, 4, 5, 6]
//=========================
isEven(x) => x % 2 == 0;
main() {
var list = [4,1,2];
var evens = list.filter(isEven);
printList(evens);
}
//=========================
var stuff = {"hello": "world", 'Dart': 'Is Cool'};
stuff.putIfAbsent('foo', () {
// calculate something awesome
return 'bar';
});
print( stuff['foo'] ); // bar
//=========================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment