简体   繁体   English

如何在一定条件后过滤 dart 中的 stream ?

[英]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:假设我有一个 stream 的人,我想按年龄 >= 40 过滤他们。我知道在 Java 中我可以这样做:

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.我是 dart 的新手,所以我真的不知道在这种语言中这个功能的等价物是什么。

Except slight syntax differences usewhere on the source and job done.除了细微的语法差异外where使用源和工作完成的位置。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM