close method
Closes this output stream and releases any system resources associated with this stream.
A closed stream cannot perform output operations and cannot be reopened. The close method of OutputStream calls flush before closing the stream.
Example
final output = FileOutputStream('output.txt');
try {
await output.writeString('Hello, World!');
// flush() is called automatically by close()
} finally {
await output.close(); // Always close in finally block
}
Throws IOException if an I/O error occurs.
Implementation
@override
@mustCallSuper
Future<void> close() async {
if (!_closed) {
_closed = true;
}
}