setDessertSelections method

void setDessertSelections(
  1. List<Dessert> desserts
)

Takes a list of Desserts and saves the row indices of selected rows into a Set.

Implementation

void setDessertSelections(List<Dessert> desserts) {
  final updatedSet = <int>{};
  for (var i = 0; i < desserts.length; i += 1) {
    var dessert = desserts[i];
    if (dessert.selected) {
      updatedSet.add(i);
    }
  }
  _dessertSelections = updatedSet;
  notifyListeners();
}