addLine method
Add a line
, autoindenting to the current value of indent. Note,
indentation is not inferred from the contents added to this printer. If a
line starts or ends an indentation block, you need to also update indent
accordingly. Also, indentation is not adapted for nested printers. If
you add a NestedPrinter to this printer, its indentation is set
separately and will not include any the indentation set here.
The location
and span
parameters indicate the corresponding source map
location of line
in the original input. Only one, location
or
span
, should be provided at a time.
Implementation
void addLine(String? line, {SourceLocation? location, SourceSpan? span}) {
if (location != null || span != null) {
_flush();
assert(location == null || span == null);
if (location != null) _items.add(location);
if (span != null) _items.add(span);
}
if (line == null) return;
if (line != '') {
// We don't indent empty lines.
_indent(indent);
_appendString(line);
}
_appendString('\n');
}