Flutter (Mobile)
Get started with Flutter for mobile development using Capsule SDK.
The Capsule SDK for Flutter allows you to easily integrate secure and scalable wallet functionalities into your mobile applications. This guide covers the installation, setup, and usage of the Capsule SDK, including handling authentication flows.
Prerequisites
To use Capsule, you need an API key. This key authenticates your requests to Capsule services and is essential for integration.
Don’t have an API key yet? Request access to the Developer Portal to create API keys, manage billing, teams, and more.
Dependency Installation
To install the Capsule SDK and required dependencies, use the following command:
Project Setup
To set up associated domains for passkey functionality in your Flutter project, you need to configure both iOS and Android platforms:
To enable passkeys on iOS, you need to set up associated domains in your Xcode project:
- Open your Flutter project’s iOS folder in Xcode
- Select your target and go to “Signing & Capabilities”
- Click ”+ Capability” and add “Associated Domains”
- Add the following domains:
webcredentials:app.beta.usecapsule.com
webcredentials:app.usecapsule.com
For more details, see the Apple Developer documentation.
Important: You must register your teamId + bundleIdentifier
with the Capsule team to set up associated domains. For example, if your Team ID is A1B2C3D4E5
and Bundle Identifier is com.yourdomain.yourapp
, provide A1B2C3D4E5.com.yourdomain.yourapp
to Capsule. This is required by Apple for passkey security. Allow up to 24 hours for domain propagation.
Using the Capsule SDK
The Capsule SDK provides two main authentication flows: creating a new user and logging in an existing user. Both flows utilize passkeys for secure and seamless authentication. Follow the steps below to implement these flows in your Flutter application.
Capsule Initialization
First, initialize the Capsule SDK within your application. This step is crucial for setting up the necessary environment.
Ensure that you have properly set up your environment variables and initialized Capsule before proceeding with user authentication.
Create New User
This flow guides you through the process of registering a new user, verifying their email, and setting up their wallet. The steps below should be executed sequentially within the same function or flow.
Check User Existence
First, check if a user with the given email already exists in the Capsule system. This will determine whether to proceed with user creation or an alternative flow.
Create New User
If the user does not exist, proceed to create a new account. This step will automatically trigger a verification email to the provided email address.
The verification email contains a code that the user must enter to verify their email address.
Verify Email and Generate Passkey
Once the user receives the verification code, verify their email. After successful verification, use the biometrics ID to generate a passkey for the user. This passkey will be used for future authentications.
Create User Wallet
Finally, create a wallet for the user. This step will provide a recovery secret that must be securely stored.
It’s crucial to securely store or display the wallet.recoverySecret
. This secret is necessary for account recovery if the user loses access to their device.
Login Existing User
This flow demonstrates how to authenticate an existing user using their email and passkey. The steps below should be executed sequentially to ensure proper authentication.
Initiate User Login
Start the login process by initiating the user login, which prompts the user to authenticate using their existing passkey.
Examples
To help you get started with the Capsule Flutter SDK, we’ve prepared a comprehensive example:
This example repository demonstrates how to handle user authentication, wallet creation, and signing messages using the Capsule SDK in a Flutter application.
Next Steps
After integrating Capsule, you can explore other features and integrations to enhance your Capsule experience. Here are some resources to help you get started:
Ecosystems
Learn how to use Capsule with popular Web3 clients and wallet connectors. We’ll cover integration with key libraries for EVM, Solana, and Cosmos ecosystems.
If you’re ready to go live with your Capsule integration, make sure to review our go-live checklist:
Troubleshooting
If you encounter issues during the integration or usage of the Capsule SDK in your Flutter application, here are some common problems and their solutions:
For more detailed troubleshooting and solutions specific to Flutter, please refer to our comprehensive troubleshooting guide:
Support
If you’re experiencing issues that aren’t resolved by our troubleshooting resources, please contact our support team for assistance. To help us serve you better, include the following information in your support request:
1
A detailed description of the problem you’re encountering.
2
Any relevant error messages or logs.
3
Steps to reproduce the issue.
4
Details about your system or environment (e.g., device, operating system, software version).
Providing this information will enable our team to address your concerns more efficiently.
Was this page helpful?