resetToForm method
Reset to a clean form — called on screen entry so a stale quote (or a terminal fault) never lingers into a new swap. A NO-OP while a step is in flight (review F1) AND — since W-swap-5 (#366) — while a COMMITTED swap is live (SwapExecuted / SwapAwaitingDeposit): re-entering the screen RE-ATTACHES to the running flow instead of wiping the one surface tracking money in motion (pre-#366 tracking was one-shot — leaving the screen orphaned a live swap with no way back). Leaving a live swap is explicit: the terminal card's Done calls startNewSwap.
The live no-op branch is a RE-ATTACH in its own right (#386, the converged HIGH): the wallet screen's Swap button pushes the screen with the live SwapExecuted still held — no attachTo call anywhere on that path — so this entry hook is where a stale synthesized-NotFound latch must re-poll. Without it, a back-nav exit from the NotFound card (the no-dismiss Done's sibling exit; resetToForm deliberately keeps the live state) re-rendered the stale heuristic with ZERO provider traffic on every subsequent direct entry for the process lifetime — a desktop host never self-heals via process death. Safe here: the screen calls this post-frame (never mid-build).
Implementation
void resetToForm() {
if (_inFlight || _live) {
final current = state;
if (current is SwapExecuted) {
_repollStaleNotFound(current.swapId);
}
return;
}
_set(const SwapFormState());
}