deleteFromStorage static method
Deletes the file system directory handle that would store sqlite3 databases when using loadFromStorage with the same path.
Implementation
static Future<void> deleteFromStorage(String path) async {
final FileSystemDirectoryHandle? parent;
final FileSystemDirectoryHandle handle;
try {
(parent, handle) = await _resolveDir(path, create: false);
// ignore: invalid_runtime_check_with_js_interop_types
} on JSAny catch (e) {
// TODO: Remove type clause (needs Dart 3.12 as a minimum version)
if (e.isA<DOMException>()) {
final asDomException = e as DOMException;
if (asDomException.name == 'NotFoundError' ||
asDomException.name == 'TypeMismatchError') {
// Directory doesn't exist, ignore.
return;
}
}
rethrow;
}
if (parent != null) {
await parent
.removeEntry(handle.name, FileSystemRemoveOptions(recursive: true))
.toDart;
}
}