close method
Closes the connection. Firestore calls it when the instance terminates.
Implementation
@override
void close() {
if (_closed != null) {
return;
}
final Future<void> closed = () async {
try {
await _worker.call('close');
} finally {
_worker.terminate();
await _releaseLock();
}
}();
_closed = closed;
// Never fails, so that the next open can simply wait for it.
late final Future<void> pending;
pending = closed.then<void>((_) {}, onError: (Object _) {}).whenComplete(
() {
if (identical(_closing[path], pending)) {
_closing.remove(path);
}
},
);
_closing[path] = pending;
}