replace method

void replace(
  1. ShortcutSurface surface
)

Replace the surface with surface.id, or push if missing.

Implementation

void replace(ShortcutSurface surface) {
  final i = _indexOf(surface.id);
  if (i < 0) {
    push(surface);
    return;
  }
  _stack[i].reset();
  _stack[i].interceptor?.onStop();
  _stack[i].attachSend(null);
  _stack[i] = surface;
  surface.attachSend(_send);
  final send = _send;
  if (send != null) {
    surface.interceptor?.onStart(send);
  }
  _notifyStack();
  onPendingChanged?.call();
}