# 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 {
      if (!isClosed) {
        try {
          await _randomAccessFile?.close();
        } catch (e) {
          throw IOException('Error closing file: ${_file.path}', cause: e);
        } finally {
          _randomAccessFile = null;
          _buffer = null;
          _bufferLoaded = false;
          _bufferPosition = 0;
          await super.close();
        }
      }
    }