queryPermission method

Future<PermissionState> queryPermission({
  1. required PermissionMode mode,
})

Queries the current permission state of the current handle.

mode: can be either read or readwrite.

Returns a PermissionState value which is one of granted, denied or prompt.

If this returns prompt the website will have to call requestPermission before any operations on the handle can be done. If this returns denied any operations will reject. Usually handles returned by the local file system handle factories will initially return granted for their read permission state. However, other than through the user revoking permission, a handle retrieved from IndexedDB is also likely to return prompt.

Implementation

Future<PermissionState> queryPermission({required PermissionMode mode}) async {
  final options = [FileSystemHandlePermissionDescriptor(mode: mode.name)];
  final permission = await promiseToFuture(callMethod(this, "queryPermission", options));

  return PermissionState.values.byName(permission);
}