toggleAll method

void toggleAll(
  1. bool check, [
  2. bool notify = true
])

操作所有CheckBox

Implementation

void toggleAll(bool check, [bool notify = true]) {
  var isChanged = false;
  checkBoxStates.forEachCanBreak((k, v) {
    if (check) {
      if (!toggle(k, check)) {
        // 勾选失败,退出循环
        return true;
      }
    } else {
      toggle(k, check);
    }
    isChanged = true;
    return false;
  });

  if (isChanged && notify) {
    setState(() {});
    _notifyChange();
  }
}