isPersistedUri function

Future<bool> isPersistedUri(
  1. Uri uri
)

Convenient method to verify if a given uri. is allowed to be write or read from SAF API's.

This uses the releasePersistableUriPermission method to get the List of allowed Uris then will verify if the uri is included in.

Implementation

Future<bool> isPersistedUri(Uri uri) async {
  final persistedUris = await persistedUriPermissions();

  return persistedUris?.any((persistedUri) => persistedUri.uri == uri) ?? false;
}