首页 > 解决方案 > Dart:如何根据标准获取列表的子集?

问题描述

食物是一个定义为:

class Food {
  String name;
  double price;
  String image;
  FoodTypes foodType;
  Food({this.name, this.price, this.image, this.foodType});
}

以下代码将在一些转换后返回完整的食物列表(定义为食物列表):

foods.map((food) {
    return FoodFrame(food);
}).toList(),

如何仅将操作应用于食物子集(例如 foodType == 'fruit')?

标签: flutterdart

解决方案


推荐阅读