Page updated Jan 16, 2024

Delete user account

Amplify Flutter v0 is now in Maintenance Mode until July 19th, 2024. This means that we will continue to include updates to ensure compatibility with backend services and security. No new features will be introduced in v0.

Please use the latest version (v1) of Amplify Flutter to get started.

If you are currently using v0, follow these instructions to upgrade to v1.

Invoke the deleteUser API to delete a user from the Auth category. This action will also sign your user out.

If your application uses a Cognito User Pool, which is the default configuration for the Amazon Cognito plugin, this action will delete the user from the Cognito User Pool. It will have no effect if you are federating with a Cognito Identity Pool alone.

Depending on your application, data associated with your user may be stored in other resources such as Amazon DynamoDB or AWS S3. It is recommended that you carefully evaluate this data and implement code to remove or otherwise sanitize it, if necessary, prior to giving users the ability to delete their own user record.

Before invoking the “delete user” API, you can first delete associated user data from the GraphQL API. For example, if you are using Amplify CLI's GraphQL transformer to persist user data via owner based access control, you could follow these instructions to delete associated user data.

This allows you to address any guidelines that require your app to delete data associated with a user who deletes their account.

1Future<void> deleteUser() async {
2 try {
3 await Amplify.Auth.deleteUser();
4 print('Delete user succeeded');
5 } on Exception catch (e) {
6 print('Delete user failed with error: $e');
7 }
8}