toggle method
勾选单个CheckBox
Implementation
bool toggle(String id, bool check, [bool notify = false]) {
// 检查是否超过用户设置的最大可勾选数
if (widget.maxChecked != null && check) {
if (checkBoxStates.count((k, v) => v) >= widget.maxChecked!) {
widget.onOverloadChecked?.call();
return false;
}
}
checkBoxStates[id] = check;
if (notify) {
setState(() {});
}
_notifyChange();
return true;
}