writeln method

void writeln([
  1. Object? obj,
  2. Iterable<TextAttribute> attributes = const []
])

Write text to the internal string buffer, followed by a newline.

Applies any active attributes (attributes for which start was called, but end was not yet called) and the additional attributes passed.

If obj is null or obj.toString() returns null only a newline is written.

Implementation

void writeln([
  Object? obj,
  Iterable<TextAttribute> attributes = const [],
]) {
  attributes.forEach(start);
  final str = obj?.toString() ?? '';
  _buffer.writeln(str);
  _length += str.characters.length + 1;
  attributes.forEach(end);
}