indentBy method
Returns _input
with indentation level changed by howMuch
.
For example, the input:
Hello World
with howMuch
of 2 will result in:
Hello
World
If howMuch
is negative, the indentation level will be decreased.
For example, the input:
Hello World
with howMuch
of -2 will result in:
Hello World
Implementation
String indentBy(int howMuch) {
final lines = _processLines();
final currentIndentationLevel = _findCommonIndentationLevel(lines);
return _indent(
lines,
currentIndentationLevel,
currentIndentationLevel + howMuch,
);
}