Alin Catalin Preda
Alin Catalin Preda

Reputation: 141

How do I filter a stream in dart after a certain criteria?

Lets say I have a stream of persons and I want to filter them by the age being >= 40. I know that in Java I can do something like this:

lp.stream().filter(p->p.getAKge()>=40).forEach(System.out::println);

I'm new to dart so I don't really know what would be the equivalent of this functionality in this language.

Upvotes: 0

Views: 196

Answers (1)

Ousmane D.
Ousmane D.

Reputation: 56393

Except slight syntax differences use where on the source and job done.

lp.where((p) => p.getAge() >= 40).forEach((p) => print(p));

Upvotes: 1

Related Questions