close abstract method

Future<void> close()
inherited

Closes this resource, relinquishing any underlying resources.

This method is invoked automatically when using try-with-resources patterns or should be called explicitly in a finally block.

The close method is idempotent - calling it multiple times should have no additional effect beyond the first call.

Implementation Note

Implementations should ensure that resources are properly released even if an exception occurs during the close operation. It's recommended to mark the resource as closed before attempting cleanup operations.

Example

@override
Future<void> close() async {
  if (_closed) return; // Idempotent
  
  try {
    await _performCleanup();
  } finally {
    _closed = true; // Always mark as closed
  }
}

Throws IOException if an I/O error occurs during closing.

Implementation

Future<void> close();