How to set all data of List<bool> to be false with some function

There are many ways to do something like this, here are a couple of them:

First, use the map method:

data = data.map<bool>((v) => false).toList();

The map method transforms every item on a list, we are using it like you wanted to use every

Second, use the filled method:

data = List.filled(data.length, false, growable: true);

The filled method makes a new list given a length and a value, in our case the length is the previous list length and the value is false.


Take a look at fillRange method for list Here is the code you want: data.fillRange(0, data.length, false);