render method

  1. @override
String render()
override

Renders the component as a string.

Implementation

@override
String render() {
  final style = renderConfig.configureStyle(Style());
  final statusText = switch (status) {
    TaskStatus.success =>
      style.foreground(Colors.success).bold().render('DONE'),
    TaskStatus.failure =>
      style.foreground(Colors.error).bold().render('FAIL'),
    TaskStatus.skipped =>
      style.foreground(Colors.warning).bold().render('SKIP'),
    TaskStatus.running => style.foreground(Colors.info).bold().render('...'),
  };

  final descLen = Style.visibleLength(description);
  final statusLen = 4; // DONE/FAIL/SKIP
  final available =
      renderConfig.terminalWidth - indent - descLen - statusLen - 2;
  final fill = available > 0 ? ' ${fillChar * available} ' : ' ';

  return '${' ' * indent}$description$fill$statusText';
}