Flutter SDK
Install and integrate the LinkTrail Flutter SDK — package linktrail_flutter, one Dart API over the native SDKs.
A thin plugin over the native LinkTrail SDKs · package linktrail_flutter on pub.dev · entry point LinkTrail · Android minSdk 26, iOS 15+. Wraps io.linktrail:sdk (Maven Central) and LinkTrailSDK (CocoaPods) behind one Dart API.
Install
flutter pub add linktrail_flutterOr add it to your app's pubspec.yaml, then flutter pub get:
dependencies:
linktrail_flutter: ^0.0.2The native SDKs are pulled in automatically — no manual Gradle or CocoaPods edits. Platform minimums the SDK requires (set them if your app targets lower): android { defaultConfig { minSdk = 26 } } and platform :ios, '15.0'.
Integrate
import 'package:linktrail_flutter/linktrail_flutter.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// One stream — fires for deferred (first-launch) AND re-engagement links:
LinkTrail.onLink.listen((event) {
router.route(event.link.path, event.link.customData);
});
LinkTrail.onError.listen((error) => debugPrint('LinkTrail: $error'));
// The API key is required. The install is tracked automatically.
await LinkTrail.configure(apiKey: 'lt_live_...');
runApp(const MyApp());
}Incoming links are captured automatically — you do not need to override MainActivity (Android) or AppDelegate/SceneDelegate (iOS). The plugin forwards App Links, Universal Links, and custom-scheme opens to the SDK on both cold start and while running. Every callback is a broadcast Stream, so you can listen from multiple places.
More
// Custom + revenue events:
await LinkTrail.trackEvent(name: 'purchase', value: 59.99, currency: 'USD');
// Cached results:
final attribution = await LinkTrail.lastAttribution;
final lastLink = await LinkTrail.lastDeepLink;
// Attribution stream (fires when an install is attributed):
LinkTrail.onAttribution.listen((attribution) { /* … */ });
// Consent-gated install (defer configure's auto-track, then call manually):
await LinkTrail.configure(apiKey: 'lt_live_...',
options: LinkTrailOptions(autoTrackInstall: false));
await LinkTrail.trackInstall();
// iOS ATT / SKAdNetwork (no-ops on Android):
await LinkTrail.requestTrackingAuthorization();
await LinkTrail.registerForSKAdAttribution();
await LinkTrail.updateConversionValue(3, coarseValue: LinkTrailCoarseConversionValue.medium);Errors arrive as typed LinkTrailException subtypes on onError, and are thrown from the Future-returning calls — so you can try/catch a specific case like LinkTrailInvalidApiKeyException.
API surface
| API | Purpose |
|---|---|
| configure(apiKey:, options:) | Initialize; auto-tracks the install |
| onLink — Stream<LinkTrailLinkEvent> | Deep link delivered (deferred + re-engagement) |
| onAttribution — Stream<LinkTrailAttribution> | Install attribution result |
| onError — Stream<LinkTrailException> | Failures (invalid key, network…) |
| handleDeepLink(uri) | Resolve a link manually (links are also auto-captured) |
| trackEvent(name:, value:, currency:) | Custom + revenue events |
| trackInstall(force:) | Manual install track (with autoTrackInstall: false) |
| lastAttribution / lastDeepLink | Cached last results |
| requestTrackingAuthorization() | ATT prompt (iOS; no-op on Android) |
| registerForSKAdAttribution() / updateConversionValue(…) | SKAdNetwork (iOS; no-op on Android) |
Deep-link setup
The plugin captures links automatically, but the OS still needs to route the link to your app. Android: declare your App Links host in AndroidManifest.xml (see below). iOS: add the Associated Domains capability with applinks:yourapp.linktrail.io, and for a custom scheme add it under CFBundleURLTypes in ios/Runner/Info.plist.
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="yourapp.linktrail.io" />
</intent-filter>