SDK Integration
PowerAuth Flutter SDK Dependency
The PowerAuth Flutter SDK is a required dependency that will be automatically installed (if not already specified in your project).
Supported Platforms
The library is available for the following Flutter 3.44.0+ platforms:
- Android 6.0 (API 23) and newer
- iOS 13.4 and newer
How To Install
1. Prerequisites
- Flutter SDK installed (Get Started)
- A working Flutter project (
flutter create my_appif starting fresh)
2. Add Dependency
Open pubspec.yaml and add:
dependencies:
# Replace VERSION_DEFINITION with the actual package version.
mtoken_sdk_flutter: VERSION_DEFINITION
Then run:
flutter pub get
3. Configure Native Platforms
Android
In android/app/build.gradle, make sure to set the minimum SDK version:
compileSdkVersion 37
minSdkVersion 23
Also, make sure to enable Java 17:
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
iOS
The SDK supports both Swift Package Manager and CocoaPods. Swift Package Manager is recommended for new projects. Ensure its support is enabled in Flutter:
flutter config --enable-swift-package-manager
Set the Runner target’s minimum deployment version to iOS 13.4 or newer in Xcode. Resolve the Dart dependencies, then build the app; Flutter and Xcode resolve the Swift packages during the iOS build:
flutter pub get
flutter build ios
No CocoaPods installation or Podfile is required when Swift Package Manager is enabled.
Existing CocoaPods-based applications remain supported. When Swift Package Manager is disabled, Flutter uses the PowerAuth plugin’s podspec and resolves its native PowerAuth2 dependency through CocoaPods.
4. Import in your Dart files
import 'package:mtoken_sdk_flutter/mtoken_sdk_flutter.dart';
import 'package:flutter_powerauth_mobile_sdk_plugin/flutter_powerauth_mobile_sdk_plugin.dart';
Future<void> createMtokenInstance() async {
final powerAuth = PowerAuth("my-instance");
// note that an activated PowerAuth instance is required. How to activate the PowerAuth instance, follow https://github.com/wultra/flutter-powerauth-mobile-sdk documentation.
// Then, use PowerAuth's helper function to create the mtoken instance:
final mtoken = await powerAuth.createMobileToken();
}