prefixFirst function

Iterable<String> prefixFirst(
  1. String prefix,
  2. Iterable<String> lines
)

Prepends prefix to the first line of lines.

If lines is empty, the result will be as well. The prefix will not be returned for an empty input.

Implementation

Iterable<String> prefixFirst(String prefix, Iterable<String> lines) sync* {
  var isFirst = true;
  for (var line in lines) {
    if (isFirst) {
      yield '$prefix$line';
      isFirst = false;
    } else {
      yield line;
    }
  }
}