可能的原因是需要处理注册失败的情况,并从 AmplifyException 中获取错误信息。可以添加一个错误处理程序并在用户注册出现错误时显示错误消息。
示例代码:
try {
final authResult =
await Amplify.Auth.signUp(
username: emailController.text.trim(),
password: passwordController.text.trim(),
options: CognitoSignUpOptions(
userAttributes: {'email': emailController.text.trim()}));
// handle successful signup
} on AmplifyException catch (e) {
print('Failed to register user - ${e.message}');
scaffoldKey.currentState.showSnackBar(
SnackBar(
content:
Text('Failed to register user - ${e.message}')));
}
上一篇:AmplifyFlutter提示“MorethanonegraphQLAPIconfigured.CouldnotinferwhichAPItocall”。
下一篇:Amplify构建失败并出现[Error:Commandfailedwithexitcode1:pipenv--venv]错误。