close method

Future<void> close([
  1. bool immediate = false
])

Closes this popover with optional immediate dismissal.

If immediate is true, skips closing animations and removes the popover immediately. Otherwise, plays the closing animation before removal.

Returns a Future that completes when the popover is fully dismissed.

Parameters:

  • immediate (bool, default: false): Whether to skip closing animations

Example:

await popover.close(); // Animated close
await popover.close(true); // Immediate close

Implementation

Future<void> close([bool immediate = false]) {
  var currentState = key.currentState;
  if (currentState != null) {
    return currentState.close(immediate);
  } else {
    entry.remove();
  }
  return Future.value();
}