indentBlock function

String indentBlock(
  1. String input,
  2. int spaces
)

Indents each line of input by spaces spaces.

Implementation

String indentBlock(String input, int spaces) {
  final prefix = ' ' * spaces;
  return input
      .split('\n')
      .map((line) => line.isEmpty ? line : '$prefix$line')
      .join('\n');
}