Flutter SDK (Dart)
Add install and purchase attribution to your Flutter app with a single Dart package.
Prerequisites
- Flutter 3.0 or later
- Dart 3.0 or later
- An Instally account with an App ID and API Key (available at app.instally.io)
Step 1: Add the dependency
Add the Instally package to your pubspec.yaml:
pubspec.yaml
dependencies:
flutter:
sdk: flutter
instally: ^1.0.0Then run the following command to fetch the package:
Terminal
flutter pub getStep 2: Configure and track install
Initialize the SDK as early as possible. You can do this in your main() function or in the initState() of your root widget. Replace the placeholder values with the App ID and API Key from your Instally dashboard.
In main()
main.dart
import 'package:flutter/material.dart';
import 'package:instally/instally.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
Instally.configure(appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY');
await Instally.trackInstall();
runApp(const MyApp());
}In initState()
my_app.dart
import 'package:flutter/material.dart';
import 'package:instally/instally.dart';
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
_initInstally();
}
Future<void> _initInstally() async {
Instally.configure(appId: 'YOUR_APP_ID', apiKey: 'YOUR_API_KEY');
await Instally.trackInstall();
}
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HomeScreen(),
);
}
}Step 3: Track purchases (optional)
To attribute revenue to referrers, call trackPurchase() after every successful in-app purchase.
purchase_handler.dart
import 'package:instally/instally.dart';
Future<void> handlePurchase(PurchaseDetails purchaseDetails) async {
if (purchaseDetails.status == PurchaseStatus.purchased) {
await Instally.trackPurchase(
productId: purchaseDetails.productID,
revenue: 9.99,
currency: 'USD',
transactionId: purchaseDetails.purchaseID ?? '',
);
}
}Important notes
No special permissions required
The Instally SDK does not use IDFA on iOS or advertising IDs on Android. No ATT prompt is needed. Attribution is handled through deterministic matching.
trackInstall()is safe to call on every app launch. It only fires once per install.trackPurchase()should be called after every successful in-app purchase.- The SDK is under 200 KB with zero external dependencies.
- Works alongside any other analytics or attribution provider.