scheduleHide static method

void scheduleHide({
  1. Object? rootId,
  2. Duration delay = const Duration(milliseconds: 125),
})

Schedules hiding the given rootId (or all roots if null) after a debounce delay.

Implementation

static void scheduleHide({
  Object? rootId,
  Duration delay = const Duration(milliseconds: 125),
}) {
  if (isLocked) return;

  if (rootId == null) {
    for (final state in _roots.values) {
      state.closeTimer?.cancel();
      state.closeTimer = Timer(delay, () {
        if (!isBranchHovered(state.rootId)) {
          hideRoot(state.rootId);
        }
      });
    }
    return;
  }

  final key = rootId;
  final state = _getState(key);
  if (state == null) return;

  state.closeTimer?.cancel();
  state.closeTimer = Timer(delay, () {
    if (!isBranchHovered(key)) {
      hideRoot(key);
    }
  });
}