tasks<T> method
Future<T>
tasks<T>(
- FutureOr<
T> body(- ProgressTracker tracker
- List<
ProgressColumn> ? columns, - bool hideFinished = false,
- ProgressBarShape barShape = ProgressBarShape.line,
- int? maxBarWidth = 30,
- ByteUnits byteUnits = ByteUnits.decimal,
Runs body with a ProgressTracker whose tasks are shown as the
output allows, and completes with what the body does, its error
thrown again; the tracker is disposed once it has ended.
- CliMode.interactive: a ProgressList of
columns(ProgressList.defaultColumns without: the mark, the label, the bar, the percent, the rate and the time left), its bars inbarShape(a thin line by default) andmaxBarWidthcells at most (null for all the room the row leaves), live in the inline session, below the prompts asked meanwhile, with the lines logged meanwhile above it; the terminal's tab shows how much of all of it is done (OSC 9;4, where the terminal takes it). Once the body ends, the list as it stands is committed in its place. WithhideFinisheda task done or skipped leaves the list, its ProgressTask.summary committed above it. - A terminal that does not redraw, or where nobody answers: each
task's label as it is set going (and as it changes while it runs),
and its summary once it ends:
✓ Downloading assets.zip • 3.4/3.4 MB • 2.1 s. - Output that is no terminal: each task's summary as it ends.
The times, rates and times left are read on the terminal's clock.
The bytes of tasks in ProgressUnit.bytes are counted as byteUnits
says, in the list and in the summaries alike: by 1000 (3.4 MB), or
by 1024 as ls -h does (3.2 MiB).
await cli.tasks(
(tracker) => Future.wait([
tracker.run(
'Downloading assets.zip',
(task) => download(task.advance),
total: size,
unit: ProgressUnit.bytes,
),
tracker.run('Building binary', (_) => build()),
]),
);
Implementation
Future<T> tasks<T>(
FutureOr<T> Function(ProgressTracker tracker) body, {
List<ProgressColumn>? columns,
bool hideFinished = false,
ProgressBarShape barShape = ProgressBarShape.line,
int? maxBarWidth = 30,
ByteUnits byteUnits = ByteUnits.decimal,
}) => runTasks(
this,
body,
columns: columns,
hideFinished: hideFinished,
barShape: barShape,
maxBarWidth: maxBarWidth,
byteUnits: byteUnits,
);