This file contains 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> _updatePassword() async { | |
setState(() { | |
_errorMessage = null; | |
}); | |
// (1) | |
if (_showPasswordUpdate && _passwordFormKey.currentState!.validate()) { | |
try { | |
await Amplify.Auth.updatePassword( | |
newPassword: _newPasswordController.text, | |
oldPassword: _passwordController.text, |
This file contains 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> _confirmEmailAddress() async { | |
try { | |
await Amplify.Auth.confirmUserAttribute( | |
userAttributeKey: CognitoUserAttributeKey.email, | |
confirmationCode: _confirmationCodeController.text, | |
); | |
setState(() { | |
_isLoading = false; | |
}); | |
if(mounted) { |
This file contains 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, |
This file contains 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
FutureBuilder<List<AuthUserAttribute>>( | |
(1) | |
future: Amplify.Auth.fetchUserAttributes(), | |
builder: (context, snapshots) { | |
if (snapshots.hasData) { | |
final data = snapshots.data; | |
return Column( | |
mainAxisSize: MainAxisSize.min, | |
(2) | |
children: data!.map( |
This file contains 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> _loginUser() async { | |
// (1) | |
if (_formKey.currentState!.validate()) { | |
setState(() { | |
_isLoading = true; | |
_errorMessage = null; | |
}); | |
try { | |
// (2) | |
final result = await Amplify.Auth.signIn( |
This file contains 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
return Form( | |
key: _formKey, | |
child: Column( | |
mainAxisSize: MainAxisSize.min, | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
TextFormField( | |
controller: _usernameController, | |
keyboardType: TextInputType.name, |
This file contains 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
@override | |
Widget build(BuildContext context) { | |
return AppBackground( | |
child: AnimatedSize( | |
duration: const Duration(milliseconds: 250), | |
(1) | |
child: FutureBuilder<AuthSession>( | |
(2) | |
future: Amplify.Auth.fetchAuthSession(), | |
builder: (context, snapshot) { |
This file contains 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> _confirmUser() async { | |
try { | |
// (1) | |
final result = await Amplify.Auth.confirmSignUp( | |
username: widget.username!, | |
confirmationCode: _confirmationCodeController.text, | |
); | |
// (2) | |
setState(() { | |
_isLoading = false; |
This file contains 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> _signUpUser() async { | |
if (_formKey.currentState!.validate()) { | |
// (1) | |
setState(() { | |
_isLoading = true; | |
_errorMessage = null; | |
}); | |
try { | |
final result = await Amplify.Auth.signUp( | |
username: _usernameController.text, |
This file contains 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> _signUpUser() async { | |
if (_formKey.currentState!.validate()) { | |
await Amplify.Auth.signUp( | |
username: _usernameController.text, | |
password: _passwordController.text, | |
options: CognitoSignUpOptions( | |
userAttributes: <CognitoUserAttributeKey, String>{ | |
CognitoUserAttributeKey.email: _emailController.text, | |
}, | |
), |