ProgressBar class
Themed progress bar for displaying determinate progress.
Usage:
- Static display (caller controls updates):
final bar = ProgressBar('Downloading');
bar.show(current: 0, total: 100);
// ... do work ...
bar.show(current: 50, total: 100);
bar.clear();
- With callback (caller provides progress):
ProgressBar('Processing').runWith((update) {
for (int i = 0; i <= 100; i++) {
update(i, 100);
}
});
Constructors
- ProgressBar(String prompt, {int width = 36, PromptTheme theme = PromptTheme.dark})
- Creates a progress bar.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- prompt → String
-
The label displayed above the progress bar.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- theme → PromptTheme
-
The theme controlling the colors used for the progress bar and text.
final
- width → int
-
The width of the progress bar in characters.
final
Methods
-
clear(
) → void -
Clears the indicator from the terminal and resets internal state.
inherited
-
initializeAutomatically(
) → void -
Captures the ambient terminal and its automatically detected execution
mode for a directly constructed indicator.
inherited
-
initializeFromTerminice(
Terminice origin) → void -
Captures the terminal and execution policy for a factory-created
indicator.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prepareFrame(
) → RenderOutput -
Prepares a RenderOutput, clears the previous frame if one was drawn,
and returns the output for the subclass to render into.
inherited
-
renderIndicator(
String plainLine, void renderRich(RenderOutput output)) → void -
Renders one indicator update according to the captured execution policy.
inherited
-
runSession(
void body(), {required String plainStart, required String plainSuccess}) → void -
Runs a callback inside a cursor-hidden terminal session, calling
clearwhen the callback finishes.inherited -
runTaskSession<
T> (Future< T> run(Terminal terminal, TerminiceFallbackMode directFallbackMode), {required String plainStart}) → Future<T> -
Adds the one start line required by task-like indicator sugar while the
existing task renderer remains responsible for its single final line.
inherited
-
runWith(
void callback(void update(int current, int total))) → void - Runs the progress bar with a callback that provides updates.
-
show(
{required int current, required int total, int shimmerPhase = 0}) → void - Shows the progress bar at the given progress.
-
toString(
) → String -
A string representation of this object.
inherited
-
trackStream<
T> (Stream< T> source, {required int total, String? message, String? success, TaskErrorMessage? failure, TaskErrorMessage? cancel, TaskCancelPredicate? isCanceled, TaskDisplay display = TaskDisplay.auto, TaskFinalBehavior finalBehavior = TaskFinalBehavior.persist, Duration interval = const Duration(milliseconds: 80)}) → Future<List< T> > -
Collects
sourcewhile advancing the progress bar once per event. -
whileRunning<
T> (FutureOr< T> run(TaskProgress progress), {required int total, String? message, String? success, TaskErrorMessage? failure, TaskErrorMessage? cancel, TaskCancelPredicate? isCanceled, TaskDisplay display = TaskDisplay.auto, TaskFinalBehavior finalBehavior = TaskFinalBehavior.persist, Duration interval = const Duration(milliseconds: 80)}) → Future<T> -
Runs
runwith a progress handle while rendering determinate progress.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited