IStatefulWidget<TSelf, TState>
Namespace: Hex1b
Assembly: Hex1b.dll
Marks a widget as supporting an externally-supplied state object of type TState. Implementing widgets expose a fluent State(TState) method that returns a copy of the widget bound to the supplied state instance.
public interface IStatefulWidget<TSelf, TState> where TSelf : Hex1bWidget, IStatefulWidget<TSelf, TState> where TState : classMethods
State(TState)
Returns a copy of the widget bound to the supplied state instance. The framework will route this exact instance into the underlying node on every reconcile, making the widget a pure view of state.
Parameters:
state(<TState>): The state object owned by the calling composite.
Returns: <TSelf>
TSelf State(TState state)Remarks
This interface is the framework-wide convention for "lifting a widget's state out of its node". The intended pairing is with inside a composite's override:
var state = ctx.UseState(() => new TextBoxState());
return ctx.TextBox().State(state);Once the parent owns the state, the widget becomes a pure view of it: the parent can mutate state.X = … between renders and those mutations are reflected on the next reconcile, without any OnXChanged shadow-syncing.
Implementations should:
store the supplied state in an internal InjectedState init-only property and route it into the underlying node during ReconcileAsync;throw if the widget also carries conflicting initial-value parameters supplied via its primary constructor (so misuse fails fast rather than silently picking one);name the fluent method exactly State — the analyzer HEX1B0001 forbids the With* prefix on widget extension and instance methods.