SpinnerModel class
A spinner widget for showing loading/activity states.
The spinner animates through frames at a configurable rate. It follows the Elm Architecture pattern and can be composed into larger components.
Example
class LoadingModel implements Model {
final SpinnerModel spinner;
final String message;
LoadingModel({SpinnerModel? spinner, this.message = 'Loading...'})
: spinner = spinner ?? SpinnerModel();
@override
Cmd? init() => spinner.tick(); // Start the animation
@override
(Model, Cmd?) update(Msg msg) {
final (newSpinner, cmd) = spinner.update(msg);
return (
LoadingModel(spinner: newSpinner, message: message),
cmd,
);
}
@override
String view() => '${spinner.view()} $message';
}
- Inheritance
-
- Object
- Model
- ViewComponent
- SpinnerModel
Constructors
- SpinnerModel({Spinner spinner = Spinners.line, int frame = 0})
- Creates a new spinner model.
Properties
- frame → int
-
The current frame index.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → int
-
The spinner's unique ID.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- spinner → Spinner
-
The spinner animation being used.
no setter
Methods
-
copyWith(
{Spinner? spinner, int? frame, int? tag}) → SpinnerModel - Creates a copy with the given fields replaced.
-
init(
) → Cmd? -
Returns an optional command to execute on program startup.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
tick(
) → Cmd - Creates a command to start the spinner animation.
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
Msg msg) → (SpinnerModel, Cmd?) -
Updates the component state in response to a message.
override
-
view(
) → String -
Renders the current model state for display.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited