writeAll method

  1. @override
void writeAll(
  1. Iterable objects, [
  2. String separator = ""
])
override

Writes the elements of objects separated by separator.

Writes the string representation of every element of objects, in iteration order, and writes separator between any two elements.

sink.writeAll(["Hello", "World"], " Beautiful ");

is equivalent to:

sink
  ..write("Hello");
  ..write(" Beautiful ");
  ..write("World");

Implementation

@override
void writeAll(Iterable<dynamic> objects, [String separator = ""]) {
  final iterator = objects.iterator;
  if (!iterator.moveNext()) return;

  if (separator.isEmpty) {
    do {
      write(iterator.current);
    } while (iterator.moveNext());
  } else {
    write(iterator.current);
    while (iterator.moveNext()) {
      write(separator);
      write(iterator.current);
    }
  }
}