How to remove all data from the box?
Either using box.clear() to clear the box or box.deleteFromDisk() to also delete the file containing the box (or the indexeddb database in the browser).
It looks like box.clear operation is not immediately applied:
box.add(0);
print(box.length); // 1
box.clear();
print(box.length); // 1
But box.deleteAll works as expected:
box.add(0);
print(box.length); // 1
box.deleteAll(box.keys);
print(box.length); // 0
@leisim: Is that the correct behavior? It doesn't seem right...
@jimmy-robert the clear method is async, you have to await for it:
await box.clear();
@erabti @leisim I really think clear should clear the in-memory data immediately, then resolve the Future once the data has been removed from disk (similar to how put works).
Is there a reason this can't or shouldn't be done?
Most helpful comment
@erabti @leisim I really think clear should clear the in-memory data immediately, then resolve the Future once the data has been removed from disk (similar to how put works).
Is there a reason this can't or shouldn't be done?