AsyncButtonController class

Observes and requests loading for an async button.

loading is a manual request owned by the application. isPending reports onPressed and onError work started by a button using this controller, and only that operation can clear it. A button's effective loading combines its loading parameter, loading, and isPending; setting loading to false never cancels or unlocks unfinished work.

The caller owns the controller and must dispose it. Buttons add and remove listeners but never dispose it. Use a controller for one logical button. It can move between button widgets, including while an animated switch or route transition briefly shows both; every button using it reflects the same state, and pending work locks each of them until it finishes.

Pending work stays on the controller it started with. If a button switches to another controller mid-operation, the new controller reports idle while the button stays locked; keep the same controller to observe that work.

Inheritance

Constructors

AsyncButtonController({bool loading = false})
Creates a controller with an optional initial manual loading request.

Properties

hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
isLoading → bool
Whether loading is requested or an operation isPending.
no setter
isPending → bool
Whether an operation started by a button with this controller is pending.
no setter
loading ↔ bool
Whether the application requests loading, independent of pending work.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited