Spinner class
A widget for displaying animated loading/waiting indicators in a TUI.
It supports automatic wall-clock time-based updates, manual frame ticks, and custom spinner frames.
Predefined Constructors
- Spinner.dots: Classic Braille dots spinner (
⠋,⠙,⠹...). - Spinner.line: Classic line/pipe character spinner (
|,/,-,\). - Spinner.pulse: Pulsing block/shade density spinner (
░,▒,▓...).
Example Usage
final spinner = Spinner.dots(
style: Style(foreground: Color(0xFF00FFFF)),
speed: Duration(milliseconds: 80),
);
Properties and Settings
| Property | Type | Description |
|---|---|---|
frames |
List<String> | The sequence of characters shown per frame. |
style |
Style | Rendering style (foreground/background color). |
speed |
Duration | Frame rate interval between animations. |
paused |
bool | Stops the animation on the first frame if true. |
- Inheritance
- Implemented types
Constructors
-
Spinner({required List<
String> frames, Style style = Style.empty, Duration speed = const Duration(milliseconds: 100), bool paused = false, Stopwatch? clockStopwatch}) - Creates a Spinner widget with custom frames.
- Spinner.dots({Style style = Style.empty, Duration speed = const Duration(milliseconds: 80), bool paused = false, Stopwatch? clockStopwatch})
-
Creates a classic 10-frame Braille dots spinner.
factory
- Spinner.line({Style style = Style.empty, Duration speed = const Duration(milliseconds: 100), bool paused = false, Stopwatch? clockStopwatch})
-
Creates a classic 4-frame rotating line spinner.
factory
- Spinner.pulse({Style style = Style.empty, Duration speed = const Duration(milliseconds: 120), bool paused = false, Stopwatch? clockStopwatch})
-
Creates a 6-frame pulsing density block spinner.
factory
Properties
- clockStopwatch → Stopwatch
-
An optional stopwatch to override the global clock, useful for rendering multiple states.
final
- currentFrame → String
-
Get the current visible frame.
no setter
-
frames
→ List<
String> -
The sequence of character frames to cycle through.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAnimatable → bool
-
Whether this object is currently animating.
no setteroverride
- key → Key?
-
The optional key for this widget.
finalinherited
- paused → bool
-
Whether the spinner animation is currently paused.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- speed → Duration
-
The time duration between frame updates.
final
- style → Style
-
The style applied to the spinner characters.
final
Methods
-
createElement(
) → Element -
Creates an Element to manage this widget's location in the tree.
inherited
-
getIntrinsicHeight(
int width) → int -
Computes the intrinsic height of this widget under the given
widthconstraint.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
Buffer buffer, Rect area) → void -
Renders the widget onto the provided
bufferwithin the specifiedarea.override -
tick(
) → void - Advance the spinner to the next frame (manual control).
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited