readLine method

  1. @override
String? readLine({
  1. Encoding encoding = utf8,
  2. int? newline,
})
override

Removes and returns characters up to but not including the next line break. A line break is either "\n" or "\r\n"; these characters are not included in the result.

On the end of the stream this method returns null, If the source doesn't end with a line break then an implicit line break is assumed. Null is returned once the source is exhausted. Use this for human-generated data, where a trailing line break is optional.

Implementation

@override
String? readLine({Encoding encoding = utf8, int? newline}) {
  newline ??= indexOf(kLF);
  if (newline == -1) {
    if (_length == 0) {
      return null;
    } else {
      return readString(encoding: encoding, count: _length);
    }
  } else {
    return _readLine(encoding, newline);
  }
}