Created
April 6, 2022 10:40
-
-
Save gerardsimons/66c4d1eb5fe91868fb6b8ea20df28ded to your computer and use it in GitHub Desktop.
firstWhere example
This file contains hidden or 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
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