Skip to content

Instantly share code, notes, and snippets.

View salihgueler's full-sized avatar
🖖
Aloha

Muhammed Salih Guler salihgueler

🖖
Aloha
View GitHub Profile
Future<void> _updatePassword() async {
setState(() {
_errorMessage = null;
});
// (1)
if (_showPasswordUpdate && _passwordFormKey.currentState!.validate()) {
try {
await Amplify.Auth.updatePassword(
newPassword: _newPasswordController.text,
oldPassword: _passwordController.text,
Future<void> _confirmEmailAddress() async {
try {
await Amplify.Auth.confirmUserAttribute(
userAttributeKey: CognitoUserAttributeKey.email,
confirmationCode: _confirmationCodeController.text,
);
setState(() {
_isLoading = false;
});
if(mounted) {
Future<void> _updateEmail() async {
setState(() {
_errorMessage = null;
});
// (1)
if (_showEmailUpdate && _emailFormKey.currentState!.validate()) {
try {
// (2)
final result = await Amplify.Auth.updateUserAttribute(
userAttributeKey: CognitoUserAttributeKey.email,
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(
Future<void> _loginUser() async {
// (1)
if (_formKey.currentState!.validate()) {
setState(() {
_isLoading = true;
_errorMessage = null;
});
try {
// (2)
final result = await Amplify.Auth.signIn(
return Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextFormField(
controller: _usernameController,
keyboardType: TextInputType.name,
@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) {
Future<void> _confirmUser() async {
try {
// (1)
final result = await Amplify.Auth.confirmSignUp(
username: widget.username!,
confirmationCode: _confirmationCodeController.text,
);
// (2)
setState(() {
_isLoading = false;
Future<void> _signUpUser() async {
if (_formKey.currentState!.validate()) {
// (1)
setState(() {
_isLoading = true;
_errorMessage = null;
});
try {
final result = await Amplify.Auth.signUp(
username: _usernameController.text,
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,
},
),