toggle method

void toggle()

Shows the tooltip if it's hidden, or hides it if it's shown.

Public so a tooltip built with KatTooltip.targetGlobalKey (no KatTooltip.child to tap) can still be triggered externally, via a GlobalKey<KatTooltipState>.

Implementation

void toggle() {
  _delayTimer?.cancel();
  _animationController.stop();
  if (_overlayController.isShowing) {
    _animationController.reverse().then((_) {
      if (mounted) _overlayController.hide();
    });
  } else {
    _updatePosition();
    _overlayController.show();
    _animationController.forward();
  }
}