block method

void block(
  1. String title, {
  2. List<String> details = const <String>[],
  3. String bullet(
    1. String
    )?,
})

Prints a block led by a colored ⏺ and followed by indented details, the way tool calls and notices appear.

Implementation

void block(String title, {List<String> details = const <String>[], String Function(String)? bullet}) {
  _endTextBlock();
  gap();
  final lines = <String>[];
  final titleLines = wrapText(title, width - 2);
  for (var index = 0; index < titleLines.length; index++) {
    lines.add('${index == 0 ? (bullet ?? Style.green)('⏺') : ' '} ${titleLines[index]}');
  }
  for (final detail in details) {
    for (final wrapped in wrapText(detail, width - 5)) {
      lines.add('${lines.length == titleLines.length ? '  ⎿  ' : '     '}$wrapped');
    }
  }
  print(lines);
}