Register or log in a user using passkeys in Flutter
Register a new user with a passkey
To create a new user account with a passkey, provide the user’s email address or phone number to passage.registerWithPasskey(). View a full registration implementation on GitHub.
final passage =PassageFlutter();voidregister(String identifier) async {try {// Register userawait passage.registerWithPasskey(identifier);// Retrieve new authenticated user infofinalPassageUser user =await passage.getCurrentUser(); } catch (error) {if (error isPassageError&& error.code ==PassageErrorCode.userCancelled) {// User cancelled passkey prompt, do nothing. } else {// Optionally try an email or sms registration method (see next page) } }}
Log in an existing user with a passkey
To authenticate an existing user with their passkey, use passage.loginWithPasskey. View a full registration implementation on GitHub.
voidlogin(String identifier) async {try {await _passage.loginWithPasskey(identifier);// Retrieve authenticated user infofinalPassageUser user =await passage.getCurrentUser(); } catch (error) {if (error isPassageError&& error.code ==PassageErrorCode.userCancelled) {// User cancelled passkey prompt, do nothing. } else {// Optionally try an email or login method (see next page) } }}