close method

  1. @override
Future<void> close()
override

Closes the stream and releases any system resources associated with it.

Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Example

final reader = FileReader('data.txt');
try {
  final content = await reader.readAll();
  processContent(content);
} finally {
  await reader.close(); // Always close in finally block
}

Throws IOException if an I/O error occurs.

Implementation

@override
Future<void> close() async {
  // No external resources to close for an in-memory stream
  super.close();
}