1
votes

I have a list with custom objects and would like to iterate it and set the value to true/false.

Seen the setAll method but would be something like I don't change only a property of each object in the list.

My object looks something like:

class Feature {
  String id;
  String title;
  String subtitle;
  IconData leftIcon;
  IconData topRightIcon;
  IconData bottomRightIcon;
  bool isEnable;
  Feature({this.title, this.subtitle, this.leftIcon, this.topRightIcon, this.bottomRightIcon, this.isEnable,this.id});
}

So the object that would like to iterate would be: List<Feature> features;

How that's possible in flutter?

1

1 Answers

6
votes

Assuming you want to set isEnable to false for each Feature in a List<Feature> you can do the following:

features.forEach((f) => f.isEnable = false);

or

for (final f in features) {
  f.isEnable = false;
}