stripIndent function
Remove up to max columns of leading indentation, returning the remainder.
Implementation
String stripIndent(String line, int max) {
var removed = 0;
var idx = 0;
while (idx < line.length && removed < max) {
final c = line.codeUnitAt(idx);
if (c == _space) {
removed += 1;
idx += 1;
} else if (c == _tab) {
removed += 4;
idx += 1;
} else {
break;
}
}
return line.substring(idx);
}