kochava_measurement 4.0.0
kochava_measurement: ^4.0.0 copied to clipboard
The Kochava Measurement SDK is a lightweight and easy to integrate library, providing first-class integration with Kochava's installation attribution and analytics platform.
example/lib/main.dart
//
// KochavaMeasurementExample (Flutter)
//
// Copyright (c) 2020 - 2026 Kochava, Inc. All rights reserved.
//
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:kochava_measurement/kochava_measurement.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _installId = 'N/A';
@override
void initState() {
super.initState();
startSdk();
}
// Start the Kochava SDK and retrieve the Kochava Device ID.
Future<void> startSdk() async {
// Start the Kochava SDK.
KochavaMeasurement.instance.registerAndroidAppGuid("YOUR_ANDROID_APP_GUID");
KochavaMeasurement.instance.registerAppleAppGuid("YOUR_APPLE_APP_GUID");
KochavaMeasurement.instance.setLogLevel(KochavaMeasurementLogLevel.Trace);
KochavaMeasurement.instance.start();
// Retrieve the Kochava Install ID.
String installId = await KochavaMeasurement.instance.retrieveInstallId();
if (!mounted) return;
setState(() {
_installId = installId;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Plugin example app')),
body: Center(child: Text('Kochava Install ID: $_installId\n')),
),
);
}
}