CognitoUserAttributeKey.parse constructor

CognitoUserAttributeKey.parse(
  1. String key
)

Parses the given Cognito attribute key.

Intended for parsing keys that have been received from Cognito. Use CognitoUserAttributeKey.custom to construct custom attribute keys, or one of the static constructors such as CognitoUserAttributeKey.name for standard attributes.

Implementation

factory CognitoUserAttributeKey.parse(String key) {
  key = key.toLowerCase();
  // Custom attributes from Cognito will always start with the required prefix
  if (hasCustomPrefix(key)) {
    return CognitoUserAttributeKey.custom(key);
  }
  return values.firstWhere(
    (attr) => attr.key == key,
    orElse: () => CognitoUserAttributeKey._unknown(key),
  );
}