close method
Flushes pending writes and releases the file handle. Idempotent: safe
to call more than once (e.g. from a finally plus an error path); the
second and later calls are no-ops.
Implementation
Future<void> close() async {
if (_closed) return;
_closed = true;
await _raf.flush();
await _raf.close();
}