handleIntercept method

  1. @override
Cmd? handleIntercept(
  1. Msg msg
)
override

Called before children during message dispatch.

Return a Cmd to intercept the message and prevent it from reaching children.

Implementation

@override
Cmd? handleIntercept(Msg msg) {
  if (_stack.isEmpty) return null;

  // Esc pops the top dialog
  if (msg is KeyMsg) {
    final key = msg.key;
    if (key.type == terminal_keys.KeyType.escape) {
      pop();
      return Cmd.none();
    }
  }
  return null;
}