Flutter SDK
DartFull-featured Appflow integration for Flutter apps on iOS and Android.
The Flutter SDK provides a Dart-native API for all Appflow v2 features. It uses platform channels to bridge to native iOS and Android functionality for purchases and push notifications, while implementing analytics, remote config, and event tracking directly in Dart for optimal performance on both platforms from a single codebase.
Installation
pubspec.yaml
dependencies:
appflow_sdk: ^2.0.0
Quick Start
main.dart
import 'package:appflow_sdk/appflow_sdk.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize Appflow
await Appflow.instance.configure('your_api_key',
options: AppflowOptions(
enableAutoTracking: true,
logLevel: LogLevel.info,
),
);
runApp(MyApp());
}
// Identify users
Appflow.instance.setUserId('user_123');
// Track events
Appflow.instance.track('tutorial_completed', properties: {
'step': 5,
'duration': 120,
});Paywalls
paywall_screen.dart
import 'package:appflow_sdk/appflow_sdk.dart';
Future<void> showPaywall() async {
final result = await Appflow.instance.presentPaywall('main_paywall');
if (result is PaywallPurchased) {
print('Purchased: ${result.productId}');
} else if (result is PaywallRestored) {
print('Purchases restored');
} else if (result is PaywallDismissed) {
print('User dismissed paywall');
} else if (result is PaywallError) {
print('Error: ${result.message}');
}
}Remote Config
config_example.dart
import 'package:appflow_sdk/appflow_sdk.dart';
// Get typed config values with defaults
final showOnboarding = Appflow.instance.getBool('show_onboarding',
defaultValue: true);
final maxRetries = Appflow.instance.getNumber('max_retries',
defaultValue: 3.0);
final welcomeMsg = Appflow.instance.getString('welcome_message',
defaultValue: 'Hello!');Push Notifications
push_setup.dart
import 'package:appflow_sdk/appflow_sdk.dart';
// Request permission
final granted = await Appflow.instance.requestPushPermission();
if (granted) {
print('Push notifications enabled');
}
// Or set token manually (e.g., from Firebase)
Appflow.instance.setPushToken(fcmToken);Key Features
Dart-Native API
Idiomatic Dart with null safety and async/await
Platform Channels
Native bridges for StoreKit 2 and Google Play Billing
Offline Queue
Events persisted to SharedPreferences, synced when online
Auto-Tracking
Screen views, sessions, and lifecycle tracked automatically
Server-Driven Paywalls
Native rendering via platform channels
Single Codebase
One integration for iOS and Android from Flutter
Requirements
Flutter 3.10+, Dart 3.0+, iOS 16+ (platform code), Android API 24+ (platform code). Dependencies: shared_preferences, http, uuid.
Related Guides