wipe method

Future<void> wipe()

Drop everything this account has written.

For the end of a session. OPFS belongs to the origin rather than to a person, so without this the next person on the same browser inherits the previous one's records.

Implementation

Future<void> wipe() async {
  final parent = await _directory(
    _rootSegments.sublist(0, _rootSegments.length - 1),
    create: false,
  );
  if (parent == null) return;
  try {
    await parent
        .removeEntry(
          _rootSegments.last,
          web.FileSystemRemoveOptions(recursive: true),
        )
        .toDart;
  } catch (_) {
    // Nothing was ever written under this account.
  }
}