suspend method
Suspends the app for the shell's job control, exactly as a Ctrl+Z that
nothing handles does: the terminal is restored for the shell, the job
the shell started stops — the app together with the hot-reload
supervisor or launcher that runs it — and the shell's fg continues it,
re-entering the terminal and repainting. Nothing in the app runs until
then: timers, streams, and animations wait for fg.
Bind a key to it when Ctrl+Z can't reach job control: a focused
TextInput or TextArea takes Ctrl+Z for undo, so an app whose field
always has focus (a chat composer, a REPL prompt) needs another key.
PosixTerminalDriver(suspendOnCtrlZ: false) doesn't refuse it; that
flag turns off only the unhandled-Ctrl+Z fallback, so an app that takes
Ctrl+Z itself can close sensitive state and then call this.
Completes with true once fg has brought the app back. Completes with
false, without suspending or touching the terminal, where
supportsSuspend is false (an app no job-control shell started among
them), while a runWithHandoff operation holds the terminal, or after
the session has ended; also when the job could not be stopped, once the
session has re-entered. A call while a suspension is under way joins it.
It never completes with an error: failing to release or reclaim the
terminal ends the session, as it does for Ctrl+Z. Call it from an
interaction or lifecycle callback, not while building.
Implementation
Future<bool> suspend() => driver is TerminalSuspendDriver
? (driver as TerminalSuspendDriver).suspend()
: Future<bool>.value(false);