removeOverlay method

Future<void> removeOverlay([
  1. bool? noAnimation
])

Removes the dropdown overlay.

This method removes the dropdown overlay. If noAnimation is set to true, the removal is instantaneous without any animation.

Implementation

Future<void> removeOverlay([bool? noAnimation]) async {
  if (noAnimation == true) {
    if (_overlayEntry != null) {
      widget.onDropdownEnd?.call();

      _overlayEntry?.remove();
      _overlayEntry = null;
      setState(() {});
    }

    return;
  }

  if (_overlayEntry != null) {
    widget.onDropdownEnd?.call();

    await _easyDropdownState?.currentState?.animationController.reverse();

    _overlayEntry?.remove();
    _overlayEntry = null;
    setState(() {});
  }
}