toggle method

void toggle({
  1. bool shouldNotify = true,
  2. String? tag,
})

Toggles the boolean state, defaulting to false if null.

Implementation

void toggle({bool shouldNotify = true, String? tag}) {
  state = !(state ?? false);
  if (shouldNotify && WidgetsBinding.instance.isRootWidgetAttached) {
    _TagRegistry.set(this, tag);
    notify();
    WidgetsBinding.instance
        .addPostFrameCallback((_) => _TagRegistry.clear(this));
  }
}