emitSource method

String emitSource({
  1. required bool format,
})

Emit the generated source.

This is safe to call multiple times.

Implementation

String emitSource({required bool format}) {
  if (_suffixes.isNotEmpty) {
    println('');
    for (final key in _suffixes.keys) {
      println(_suffixes[key]!);
    }
    _suffixes.clear();
  }

  var source = _buffer.toString();

  // We don't always want to format the source (for example, we don't want to
  // format if we're creating annotated locations of source elements).
  if (format) {
    source = formatter.format(source);
  }

  return source;
}