Flutter Quickstart
This page adds Bubbl to a Flutter app.
Requirements
- Flutter 3.22 or newer.
- Dart 3.8 or newer.
- Android API 27+.
- iOS 15+.
- Firebase configured if you want push notifications.
Install
Add the package:
dependencies:
bubbl_flutter_sdk: ^4.0.2
Run:
flutter pub get
Boot the SDK
import 'package:bubbl_flutter_sdk/bubbl_flutter_sdk.dart';
Future<void> bootBubbl() async {
final result = await BubblSdk.instance.boot(
const BubblConfig(
apiKey: String.fromEnvironment('BUBBL_API_KEY'),
environment: BubblEnvironment.production,
enablePushHandling: true,
enableLocationTracking: false,
),
);
debugPrint('Bubbl ready: ${result.ready}');
}
Run with:
flutter run --dart-define=BUBBL_API_KEY=<YOUR_BUBBL_API_KEY>
Use BubblEnvironment.production for the live Bubbl environment.
Android setup
Set your Android minimum SDK to 27 or newer. Configure Firebase in the Android app if you want push notifications.
For a Kotlin Gradle Flutter project, update android/app/build.gradle.kts:
android {
defaultConfig {
minSdk = 27
}
}
On Android 13+, request notification permission before expecting visible notifications.
For Firebase push, add FlutterFire:
flutter pub add firebase_core firebase_messaging
flutterfire configure
iOS setup
Set your iOS deployment target to 15 or newer. Configure Push Notifications, Background Modes, APNs, and Firebase if you want push notifications.
Firebase token forwarding
Initialize Firebase before booting Bubbl:
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'firebase_options.dart';
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
Forward an FCM token after Firebase gives it to your app:
final token = await FirebaseMessaging.instance.getToken();
if (token != null) {
await BubblSdk.instance.registerPushToken(token);
}
Forward foreground Firebase data payloads:
FirebaseMessaging.onMessage.listen((RemoteMessage message) async {
await BubblSdk.instance.handleFirebasePayload(message.data);
});
First verification
final diagnostics = await BubblSdk.instance.diagnostics();
debugPrint('Bubbl diagnostics: $diagnostics');
Expected signs of a healthy setup:
sdkVersionis4.0.2.bootedis true after boot.platformisflutter.