build method
Initialize a Notifier.
It is safe to use Ref.watch or Ref.listen inside this method.
If a dependency of this Notifier (when using Ref.watch) changes,
then build will be re-executed. On the other hand, the Notifier
will not be recreated. Its instance will be preserved between
executions of build.
If this method throws, reading this provider will rethrow the error.
Implementation
@override
SendState build() {
// A watched-dep change (the session flips) RE-RUNS build() on the SAME
// notifier, firing the prior cycle's onDispose first → `_disposed` would
// stick `true` and wedge every later `_set` (#330 — one identity switch
// left the screen permanently dead). Reset it each build so the controller
// stays live across a session change; the INSTANCE-IDENTITY guards on the
// post-await arms keep the old cycle's in-flight continuations from
// writing into the new one.
_disposed = false;
// A rebuild is a NEW flow: the identity switch that triggers it resets the
// machine to a clean form, and anything a previous entry was waiting on
// belongs to the flow that ran under the previous identity.
_flowId++;
ref.onDispose(() => _disposed = true);
// Cached for the actions. The session seam can legitimately flip to null (the
// wallet closed) — `build()` re-runs and resets to a clean form, which is the
// honest behavior (a send screen with no live wallet must not hold a stale
// proposal).
_session = ref.watch(walletSessionProvider);
return const SendForm();
}