Flutter keeps throwing an error, while defining CognitoSignUpOptions
489
The solution is quiet simple.
You have to change the constructor of the Map:
Map<CognitoUserAttributeKey, String> userAttributes = {
CognitoUserAttributeKey.email: '[email protected]',
CognitoUserAttributeKey.phoneNumber: '+15559101234',
};
void registerAccount() async {
await Amplify.Auth.signUp(
username: 'myusername',
password: 'mysupersecurepassword',
options: CognitoSignUpOptions(
userAttributes: userAttributes)
);
}
This solves the problem.
Author by
Timon Schramm
Updated on January 02, 2023Comments
-
Timon Schramm over 1 year
Error: The argument type 'Map<String, String>' can't be assigned to the parameter type 'Map<CognitoUserAttributeKey, String>'.
When I looked up the error there was no information about it.
On the AWS documentation they recommend this code, which leads to the error:
Map<String, String> userAttributes = { 'email': '[email protected]', 'phone_number': '+15559101234', // additional attributes as needed }; SignUpResult res = await Amplify.Auth.signUp( username: 'myusername', password: 'mysupersecurepassword', options: CognitoSignUpOptions( userAttributes: userAttributes ) );