Skip to content

Instantly share code, notes, and snippets.

@felipecarvalho
Last active March 14, 2019 21:40
Show Gist options
  • Select an option

  • Save felipecarvalho/32780de6b46a387d621344f05ed54c63 to your computer and use it in GitHub Desktop.

Select an option

Save felipecarvalho/32780de6b46a387d621344f05ed54c63 to your computer and use it in GitHub Desktop.
Filtering values from a object in Dart language
// Created by Felipe Carvalho [http://github.com/felipecarvalho]
// You can play with this code on DartPad [https://dartpad.dartlang.org/32780de6b46a387d621344f05ed54c63]
List<Map<String, dynamic>> _fruits = [
{"id": 0, "name": "Orange"},
{"id": 1, "name": "Mango"},
{"id": 2, "name": "Apple"},
];
void main() {
List myFruit = _fruits.where((value) => value['name'] == 'Apple').toList();
return print('My favorite fruit is ${myFruit[0]['name']}');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment