switchTo method

void switchTo(
  1. bool value
)

Switches the state of the checkbox to the given value.

This method updates the checkbox to reflect the provided value.

value - The new state of the checkbox. If true, the checkbox will be checked; if false, the checkbox will be unchecked.

Implementation

void switchTo(bool value) {
  if (value) {
    _animationController.forward();
    if (widget.onChanged != null) {
      widget.onChanged!(true);
    }
  } else {
    _animationController.reverse();
    if (widget.onChanged != null) {
      widget.onChanged!(false);
    }
  }
  HapticFeedback.selectionClick();
}