Created
August 26, 2022 15:11
-
-
Save salihgueler/b1a4e244caee30b40b7f32b314aa2fd2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<void> _updateEmail() async { | |
setState(() { | |
_errorMessage = null; | |
}); | |
// (1) | |
if (_showEmailUpdate && _emailFormKey.currentState!.validate()) { | |
try { | |
// (2) | |
final result = await Amplify.Auth.updateUserAttribute( | |
userAttributeKey: CognitoUserAttributeKey.email, | |
value: _emailController.text, | |
); | |
setState(() { | |
_showEmailUpdate = false; | |
}); | |
// (3) | |
if (result.nextStep.updateAttributeStep == 'CONFIRM_ATTRIBUTE_WITH_CODE' && mounted) { | |
context.go('/confirm-user'); | |
} else { | |
logger.info('Update completed'); | |
} | |
} on Exception catch (error) { | |
logger.error('An error occurred: $error'); | |
} | |
} else { | |
// (4) | |
setState(() { | |
_showEmailUpdate = true; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment