Skip to content

Instantly share code, notes, and snippets.

@gerardsimons
Created April 6, 2022 10:40
Show Gist options
  • Save gerardsimons/66c4d1eb5fe91868fb6b8ea20df28ded to your computer and use it in GitHub Desktop.
Save gerardsimons/66c4d1eb5fe91868fb6b8ea20df28ded to your computer and use it in GitHub Desktop.
firstWhere example
class Item {
final int i;
final bool show;
Item(this.i, this.show);
String toString() {
return 'Item i=$i show=$show';
}
}
void main() async {
final list = <Item>[];
for(int i = 0 ; i < 4 ; i++) {
list.add(Item(i, i==2));
}
print(list);
print("firstWhere = ${list.firstWhere((x) => x.show)}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment