verify static method Null safety

bool verify(
  1. List<AuthScope>? requiredScopes,
  2. List<AuthScope>? providedScopes
)

Returns true if that providedScopes fulfills requiredScopes.

For all requiredScopes, there must be a scope in requiredScopes that meets or exceeds that scope for this method to return true. If requiredScopes is null, this method return true regardless of providedScopes.

Implementation

static bool verify(
  List<AuthScope>? requiredScopes,
  List<AuthScope>? providedScopes,
) {
  if (requiredScopes == null) {
    return true;
  }

  return requiredScopes.every((requiredScope) {
    final tokenHasValidScope = providedScopes
        ?.any((tokenScope) => requiredScope.isSubsetOrEqualTo(tokenScope));

    return tokenHasValidScope ?? false;
  });
}