Flutter SDK
Flutter plugin (growwise_flutter) wrapping the native Android GrowWise SDK via MethodChannel. Push, analytics, identity, location, logging, and automatic page_visited tracking. Current host support: Android.
Overview
Add growwise_flutter to your Flutter app, configure the Android host (Firebase + notification icon), then initialize before runApp. Native push styles and in-app campaigns are handled by the Android SDK underneath.
- Package: growwise_flutter (https://pub.dev/packages/growwise_flutter)
- minSdkVersion ≥ 21 on Android
- API surface: initialize, logIn, logEvent, logout, setLocation, setLogLevel, setPushToken, handleFcmPayload, logCrash
Setup & installation
dependencies:
growwise_flutter: ^1.2.2flutter pub getAndroid host configuration
Configure Firebase and icons under android/.
- Put google-services.json in android/app/
- Add white silhouette drawable android/app/src/main/res/drawable/ic_notification.xml (or .png)
- Pass resource name without extension to smallIconName
android {
defaultConfig {
minSdkVersion 21
}
}buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.4.2'
}
}apply plugin: 'com.google.gms.google-services'Push when you already use firebase_messaging
Android allows only one FirebaseMessagingService. If your app already handles FCM, remove the GrowWise default listener and forward tokens and payloads from Dart.
dependencies:
firebase_core: ^3.0.0
firebase_messaging: ^15.0.0
growwise_flutter: ^1.2.2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application ...>
<service
android:name="com.growwise.sdk.fcm.GrowWiseFirebaseService"
tools:node="remove" />
<!-- your activity, etc. -->
</application>
</manifest>import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:growwise_flutter/growwise_flutter.dart';
Future<void> setupGrowWisePush() async {
await Firebase.initializeApp();
final messaging = FirebaseMessaging.instance;
await messaging.requestPermission(alert: true, badge: true, sound: true);
// Current token
final token = await messaging.getToken();
if (token != null) {
await GrowWise.setPushToken(token);
}
// Token refresh
messaging.onTokenRefresh.listen(GrowWise.setPushToken);
}Future<bool> forwardToGrowWise(RemoteMessage message) async {
final data = message.data.map((k, v) => MapEntry(k, v.toString()));
return GrowWise.handleFcmPayload(data);
}
// Foreground
FirebaseMessaging.onMessage.listen((message) async {
final handled = await forwardToGrowWise(message);
if (!handled) {
// Your app's own push handling
}
});
// User tapped notification (app in background)
FirebaseMessaging.onMessageOpenedApp.listen(forwardToGrowWise);
// Cold start from notification
final initial = await FirebaseMessaging.instance.getInitialMessage();
if (initial != null) {
await forwardToGrowWise(initial);
}@pragma('vm:entry-point')
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
await GrowWise.initialize(
apiKey: 'YOUR_API_KEY',
smallIconName: 'ic_notification',
);
final data = message.data.map((k, v) => MapEntry(k, v.toString()));
await GrowWise.handleFcmPayload(data);
}
// In main(), before runApp:
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);Quick Start
A simple example of initializing and running the app.
import 'package:flutter/material.dart';
import 'package:growwise_flutter/growwise_flutter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await GrowWise.initialize(
apiKey: 'YOUR_API_KEY',
smallIconName: 'ic_notification',
logLevel: GrowWiseLogLevel.debug,
appVersion: '1.0.0', // optional
);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorObservers: [GrowWiseNavigatorObserver()],
home: Scaffold(
appBar: AppBar(title: const Text('GrowWise Demo')),
body: Center(
child: FilledButton(
onPressed: () => GrowWise.logEvent('button_clicked'),
child: const Text('Track event'),
),
),
),
);
}
}Identify user (logIn)
Link a unique user ID and profile traits to the current device session. Call this after your app login succeeds.
await GrowWise.logIn(
'user_12345', // unique user identifier (email, UUID, etc.)
{
'Name': 'Jane Doe',
'Email': 'jane@example.com',
'membership': 'Premium',
'signup_date': '2026-08-16',
},
);Track events (logEvent)
Track user actions and send them to GrowWise. Properties are optional. The SDK queues events offline and syncs them in the background.
// Event name only
await GrowWise.logEvent('app_opened');
// Event with custom properties
await GrowWise.logEvent('product_viewed', {
'item_id': 'prod_headphone_2026',
'price': 199.99,
'in_stock': true,
});
// Purchase / conversion example
await GrowWise.logEvent('purchase_completed', {
'order_id': 'ORD-1001',
'amount': 49.99,
'currency': 'USD',
});Automatic page tracking
Register GrowWiseNavigatorObserver on MaterialApp.navigatorObservers to auto-log page_visited events whenever a named route is pushed, replaced, or popped.
MaterialApp(
navigatorObservers: [GrowWiseNavigatorObserver()],
routes: {
'/': (_) => HomeScreen(),
'/product': (_) => ProductScreen(),
},
);Logout
When the user signs out, reset the authenticated profile and start a fresh anonymous session on the device.
await GrowWise.logout();Other APIs
- GrowWise.setPushToken(token) — Register FCM token
- GrowWise.handleFcmPayload(data) — Forward FCM data payloads
await GrowWise.setLocation(37.7749, -122.4194);
await GrowWise.setLocation(null, null); // clearawait GrowWise.setLogLevel(GrowWiseLogLevel.verbose);
await GrowWise.setLogLevel(GrowWiseLogLevel.none);await GrowWise.logCrash(
'StateError',
'Bad state: No element',
stackTraceString,
);Flutter checklist
- Plugin in pubspec.yaml
- minSdkVersion ≥ 21
- google-services.json in android/app/
- Google Services plugin applied
- ic_notification drawable exists
- GrowWise.initialize before runApp
- Notification permission on Android 13+