Skip to content

Instantly share code, notes, and snippets.

@salihgueler
Created August 26, 2022 15:07
Show Gist options
  • Save salihgueler/44dd4ebc0b99614fcb7b70ebc69f1f34 to your computer and use it in GitHub Desktop.
Save salihgueler/44dd4ebc0b99614fcb7b70ebc69f1f34 to your computer and use it in GitHub Desktop.
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(
(element) {
(3)
if (element.userAttributeKey == CognitoUserAttributeKey.emailVerified) {
if (element.value == 'false') {
return Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () {
Amplify.Auth.resendUserAttributeConfirmationCode(
userAttributeKey: CognitoUserAttributeKey.email,
);
context.go('/confirm-user');
},
child: const AppButton(
buttonText: 'Confirm Email Change',
isLoading: false,
),
),
);
} else {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'key: ${element.userAttributeKey}; value: ${element.value}',
),
);
}
} else {
(4)
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'key: ${element.userAttributeKey}; value: ${element.value}',
),
);
}
},
).toList(growable: false),
);
} else {
(5)
return const SizedBox(
height: 100,
child: Center(
child: CircularProgressIndicator(),
),
);
}
},
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment