scopesFromString function

Set<Scope> scopesFromString(
  1. String s
)

Converts a string to a set of Scope.

Implementation

Set<Scope> scopesFromString(String s) {
  if (s == null) {
    return null;
  }
  // Scopes are space separated.
  var stringSet = Set<String>.from(s.split(' ').map((x) => x.trim()));
  if (stringSet.contains('all')) {
    return {Scope.userProfile, Scope.userTerritory, Scope.userAccountStatus};
  }
  return Set<Scope>.from(
    stringSet.map((x) => scopeFromString(x)).whereType<Scope>(),
  );
}