To integrate Portal, an organization adds a client library to their mobile app and a few server API endpoints.
Installation
Add theportal_flutter package to your Flutter project.
Setup
Add the following to yourpubspec.yaml:
The Portal Flutter SDK is a federated plugin with separate Android and iOS implementations.
Platform Configuration
Android
Add the following to yourandroid/app/build.gradle:
iOS
Deployment target
The iOS implementation requires a deployment target of iOS 15.0 or higher. Set the iOS Deployment Target to 15.0 or higher in Xcode (Runner → General → Minimum Deployments), or withplatform :ios, '15.0' in ios/Podfile if you use CocoaPods.
Swift Package Manager
Swift Package Manager is on by default from Flutter 3.44 onward, and requires no further setup — the plugin declares its own native dependencies and Xcode resolves them when you build. On earlier Flutter versions SPM is opt-in, so those projects fall back to CocoaPods and need the CocoaPods setup below. If SPM is turned off, re-enable it.flutter config applies to every project for your user
account:
pubspec.yaml, and that takes precedence over the
flutter config setting — remove this block if the command alone has no effect:
CocoaPods
Only needed on Flutter versions before 3.44, or when Swift Package Manager has been disabled. In your app’sios/Podfile, match the platform to the deployment target you set above and
declare PortalSwift:
PortalSwift version the plugin depends on.
Initializing Portal
To initializePortal in your application, call the initialize method with your Client API Key. The rpcConfig parameter is a map of CAIP-2 Chain IDs to their respective RPC URLs.
To have Portal sign your end users in instead of using a Client API Key, pass
the
session from Client Auth in place of apiKey. Pass
exactly one of the two.Optional Configuration
Theinitialize method accepts additional optional parameters:
If you are using Client Session Tokens (CSTs), this hint is for you.When your user’s CST expires, the next call that reaches Portal throws a
PortalException with code CREDENTIAL_REJECTED, whose isCredentialRejected is true, whichever method you called. Fetch a new CST from your backend, call initialize again with it, and retry. details starts with the failed operation’s code, such as CREATE_WALLET_ERROR.With Client Auth there is no CST for your backend to refresh. A rejected session emits on Portal().onSessionInvalidated, and Portal calls then throw a PortalException with code SESSION_INVALIDATED, whose requiresReauthentication is true. The user signs in again.