close method

Future<void> close()

Writes the current snapshot to path.

Successful mutations already persist; this is a final write a caller can await before discarding the store. It does not invalidate the instance: a later upsert still works and still persists.

Does nothing when the store is empty and path does not yet exist, so opening and closing a missing path will not create an empty file.

Implementation

Future<void> close() async {
  if (await _inner.count() == 0 && !await File(path).exists()) {
    return;
  }
  await _persist();
}