readAll method

  1. @override
Future<String> readAll()
override

Reads all remaining characters from the reader.

This method reads from the current position until the end of the reader is reached. The returned string contains all the characters that were read.

Returns

A String containing all remaining characters in the reader.

Example

final reader = FileReader('document.txt');
try {
  final content = await reader.readAll();
  print('Document content:');
  print(content);
} finally {
  await reader.close();
}

Throws IOException if an I/O error occurs. Throws StreamClosedException if the reader has been closed.

Implementation

@override
Future<String> readAll() async {
  await _ensureOpen();

  if (_buffer == null) {
    return '';
  }

  final result = _buffer!.substring(_bufferPosition);
  _bufferPosition = _buffer!.length;
  return result;
}