passkeyErrorMessage function
Maps a ceremony / native-authenticator error to a user-facing message.
Implementation
String passkeyErrorMessage(Object error, {bool setup = false}) {
final action = setup ? 'setup' : 'sign-in';
if (error is PasskeyAuthCancelledException) {
return 'Passkey $action was cancelled.';
}
if (error is DomainNotAssociatedException) {
return 'Passkeys are not enabled for this app yet.';
}
if (error is NoCredentialsAvailableException) {
return setup ? 'Passkey $action failed.' : 'No passkey found for this account.';
}
if (error is DeviceNotSupportedException) {
return 'Passkeys are not supported on this device.';
}
return 'Passkey $action failed.';
}