Effective Dart warns about avoiding forEach. Use build in for-in instead.
Is there any better way? I want to wait and return.
List<PromotionModel> allPromotion = //add data from api;
Future<List<PromotionModel>> filterPromotion() async {
List<PromotionModel> temp = [];
if(!check){
return allPromotion;
}else{
await Future.forEach(allPromotion, (v) async {
if(v.vendoruid == uid){
temp.add(v);
}
});
return temp;
}
}
allPromotion?allPromotiontype is function type... ->List<PromotionModel>Iterable.forEachnot aboutFuture.forEach- btw why do you needFuture.forEachin your case? why dont you simply useIterable.where?temp. that's why I used. Is there any other way?