Clerk Flutter SDK
SDK reference

User management

Manage the signed-in user with the Clerk Flutter SDK.

Use ClerkAuthState methods to manage the current user's account. Access the auth state with ClerkAuth.of(context) and the current user with ClerkAuth.of(context).user.

Access the current user

The following example demonstrates how to access the current user through an instance of ClerkAuth.

final auth = ClerkAuth.of(context);
final user = auth.user; // User? (null if not signed in)

Update user

The following example demonstrates how to update the user's profile fields such as username, firstName, and lastName.

final auth = ClerkAuth.of(context);

await auth.updateUser(
  username: 'janedoe',
  firstName: 'Jane',
  lastName: 'Doe',
);

Set profile image

The following example demonstrates how to set the user's profile image with a dart:io File object.

final auth = ClerkAuth.of(context);

await auth.updateUserImage(imageFile); // imageFile is a dart:io File

Delete profile image

The following example demonstrates how to delete the user's profile image.

final auth = ClerkAuth.of(context);

await auth.deleteUserImage();

Email addresses

Add email address

The following example demonstrates how to add an email address to the user's account.

final auth = ClerkAuth.of(context);

await auth.addIdentifyingData(
  'jane@example.com',
  IdentifierType.emailAddress,
);

Verify email address

The following example demonstrates how to verify an email address with the code sent to the user.

final auth = ClerkAuth.of(context);

final email = auth.user?.emailAddresses
    ?.where((e) => e.identifier == 'jane@example.com')
    .firstOrNull;

if (email == null) return;

// Verify the code
await auth.verifyIdentifyingData(email, '123456');

Remove email address

The following example demonstrates how to remove an email address from the user's account.

final auth = ClerkAuth.of(context);

final email = auth.user?.emailAddresses
    ?.where((e) => e.identifier == 'jane@example.com')
    .firstOrNull;

if (email == null) return;

await auth.deleteIdentifyingData(email);

Phone numbers

Add phone number

The following example demonstrates how to add a phone number to the user's account.

final auth = ClerkAuth.of(context);

await auth.addIdentifyingData(
  '+15551234567',
  IdentifierType.phoneNumber,
);

Verify phone number

The following example demonstrates how to verify a phone number with the code sent to the user.

final auth = ClerkAuth.of(context);

final phone = auth.user?.phoneNumbers
    ?.where((p) => p.identifier == '+15551234567')
    .firstOrNull;

if (phone == null) return;

await auth.verifyIdentifyingData(phone, '123456');

Remove phone number

The following example demonstrates how to remove a phone number from the user's account.

final auth = ClerkAuth.of(context);

final phone = auth.user?.phoneNumbers
    ?.where((p) => p.identifier == '+15551234567')
    .firstOrNull;

if (phone == null) return;

await auth.deleteIdentifyingData(phone);

Passkeys

Create passkey

The following example demonstrates how to create a passkey for the user.

final auth = ClerkAuth.of(context);

await auth.createPasskey();

Remove passkey

The following example demonstrates how to remove a passkey from the user's account.

final auth = ClerkAuth.of(context);

final passkey = auth.user?.passkeys?.first;

await auth.deleteIdentifyingData(passkey!);

External accounts

Remove external account

The following example demonstrates how to remove an external account (OAuth provider) from the user's account.

final auth = ClerkAuth.of(context);

final account = auth.user?.externalAccounts?.first;

await auth.deleteExternalAccount(account: account!);

Passwords

Update password

The following example demonstrates how to update the user's password.

final auth = ClerkAuth.of(context);

await auth.updateUserPassword(
  'old-password',
  'new-password',
);

To keep other sessions active after the password change, pass signOut: false.

await auth.updateUserPassword(
  'old-password',
  'new-password',
  signOut: false,
);

Delete password

The following example demonstrates how to delete the user's password. The user must have another active factor (e.g. an email address or phone number) to use this method.

final auth = ClerkAuth.of(context);

await auth.deleteUserPassword('current-password');

Delete user

Permanently deletes the current user's account. Only available if your Clerk instance has self-deletion enabled.

final auth = ClerkAuth.of(context);

await auth.deleteUser();

On this page