toggle method Null safety

void toggle()
inherited

If the state is bool, toggle it and notify listeners

This is a shortcut of:

If the state is not bool, it will throw an assertion error.

Implementation

void toggle() {
  assert(T == bool);
  setState((s) => !(_state as bool));
}