parseCredentialState function

CredentialState parseCredentialState(
  1. String? credentialState
)

Parses the string represenation of a CredentialState to its enum value.

The values are aligned with the native implementations.

Throws a PlatformException in case of unsupported credentialState arguments.

Implementation

CredentialState parseCredentialState(String? credentialState) {
  switch (credentialState) {
    case 'authorized':
      return CredentialState.authorized;

    case 'revoked':
      return CredentialState.revoked;

    case 'notFound':
      return CredentialState.notFound;

    default:
      throw PlatformException(
        code: 'unsupported-value',
        message: 'Unsupported credential state: $credentialState',
      );
  }
}