Flutter SDK
The plugin is installed from its GitHub repository, pinned to a release tag, until the pub.dev publish lands — so there is no flutter pub add linksense yet. Its API may change between 0.x releases; pin the tag and review the changelog before upgrading.
Overview
The plugin is a thin bridge over the native iOS and Android SDKs (0.3.0). All attribution work happens in the native layer; the Dart API is a typed adapter. It gives you:
- Install-time attribution and deferred deep linking — the link a user tapped before installing, delivered on a Dart stream.
- Automatic link observation — Universal Links and App Links that open your app are reported to your LinkSense analytics, with no
AppDelegateorMainActivitycode. - Paste-to-attribute on iOS, without the system paste prompt.
- Link CRUD — create, read, update and delete dynamic links from the device.
Prerequisites
- Flutter 3.3+ / Dart 3.3+
- iOS 16.0+ deployment target; Android
minSdk24 - An SDK key from your LinkSense project (open your project's SDK Keys tab)
- iOS and Android only — web and desktop are not supported, so calls there throw
MissingPluginException
Installation
Add the plugin to your pubspec.yaml as a git dependency, then run flutter pub get:
dependencies: linksense: git: url: https://github.com/LinkSense-net/linksense-flutter.git ref: v0.3.0On iOS the native SDK is built into the plugin, so it works with both Swift Package Manager and CocoaPods and there is nothing else to add. On Android it pulls net.linksense:sdk:0.3.0 from Maven Central.
Platform Setup
iOS — add the Associated Domains capability with applinks:<your-project>.linksense.net (see iOS Deep Linking). That's all: the plugin observes Universal Links itself.
Android — declare the App Link intent filter on your host activity in AndroidManifest.xml (see Android Deep Linking for assetlinks.json):
<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="<your-project>.linksense.net" /></intent-filter>The plugin only observes links — on Android the intent is not consumed — so keep routing links with your own router (go_router, app_links, …). A link that cold-launches the app is held until configure runs.
Configuration
Call configure once at startup, subscribe to deferredDeepLinks (and deepLinks if you want link opens), then call start:
import 'package:linksense/linksense.dart'; Future<void> bootstrap() async { await LinkSense.instance.configure(const LinkSenseConfiguration( sdkKey: 'ls_sdk_<project>_<random>', enableClipboard: false, // iOS only )); // The link that led to this install (first launch only), or null. LinkSense.instance.deferredDeepLinks.listen((uri) { if (uri != null) appRouter.handle(uri); }); // Every Universal Link / App Link that opens the app, as LinkSense resolved it. LinkSense.instance.deepLinks.listen((uri) { // Analytics or logging; keep routing in your own router. }); await LinkSense.instance.start();}| Field | Type | Required | Description |
|---|---|---|---|
sdkKey | String | Required | Your project SDK key (format: ls_sdk_<project>_<random>). Generate one in your project's SDK Keys tab. |
enableClipboard | bool | Optional | iOS only. Read the pasteboard once on first launch for clipboard-based attribution; iOS shows its paste prompt when this reads. Default false — see Paste-to-Attribute for a prompt-free alternative. |
enableInstallReferrer | bool | Optional | Android only. Use the Google Play Install Referrer for high-confidence attribution. Default true. |
enableFingerprint | bool | Optional | Android only. Send the probabilistic fingerprint used when no Install Referrer click is available. Default true. iOS always uses it. |
Later calls are ignored. A malformed SDK key throws LinkSenseInvalidSdkKeyException and leaves the SDK unconfigured, so every later call fails with LinkSenseNotConfiguredException. Copy the key from the dashboard rather than retyping it.
Handling Deep Links
The plugin has two broadcast streams of Uri?:
deferredDeepLinks— the install result, once per launch afterstart(): the matched link on the first launch after install, otherwisenull(no match, or any later launch).deepLinks— every Universal Link / App Link that opens the app, as LinkSense resolved it.
Your own router also sees link opens, so route from it and use deepLinks only for analytics or logging, or route only from deepLinks. Treat null on deferredDeepLinks as "nothing to route", not as "organic install". Events emitted before you subscribe are buffered per stream and delivered, in order, when you do.
Paste-to-Attribute
On iOS 16+, reading the clipboard shows a system prompt. If your onboarding asks users to paste an invite link, hand the pasted text to the SDK: the user's own paste supplies consent, so there is no prompt, and the install is attributed to that link. On Android this always returns null — the Play Install Referrer covers that case.
// From your own "paste your invite link" field. No iOS paste prompt.final deepLink = await LinkSense.instance.submitPastedLink(text);if (deepLink != null) appRouter.handle(deepLink);Link CRUD
createLink(CreateLinkOptions), getLink(id), updateLink(id, UpdateLinkOptions) and deleteLink(id) return Futures; the first three resolve to a LinkSenseLink.
final link = await LinkSense.instance.createLink(const CreateLinkOptions( name: 'Spring promo', slug: 'spring-promo', tags: ['campaign:spring-2026'], metadata: {'campaign_id': 42, 'channel': 'email'},));print('Created: ${link.fullUrl}'); await LinkSense.instance.updateLink(link.id, UpdateLinkOptions( name: 'Spring promo (v2)', ogTitle: const FieldUpdate.clear(), // explicitly clear the og:title desktopUrl: const FieldUpdate.set('https://example.com/spring'),)); await LinkSense.instance.deleteLink(link.id);Clearable UpdateLinkOptions fields are FieldUpdate<T>?: leave one null to keep the server value, pass FieldUpdate.set(value) to change it, or const FieldUpdate.clear() to null it server-side. name, tags and iosClipboardEnabled are plain nullable values and cannot be cleared. slug can only be set at create time. Links you read back expose their custom data as link.metadata.
Error Handling
Every error is a LinkSenseException. Catch it broadly, or narrow with the typed subclasses:
try { await LinkSense.instance.createLink(options);} on LinkSenseRateLimitedException catch (e) { await Future.delayed(Duration(seconds: e.retryAfterSeconds ?? 1));} on LinkSenseInvalidInputException catch (e) { for (final entry in e.fieldErrors.entries) { print('${entry.key}: ${entry.value}'); }} on LinkSenseAccessDeniedException catch (e) { // Plan limit or platform not allowed. if (e.upgradeRequired) showUpgradePrompt(e.plan, e.currentUsage, e.limit);} on LinkSenseForbiddenCrossScopeException { // The SDK key isn't allowed to change that link.} on LinkSenseException catch (e) { print('LinkSense failed: ${e.code} — ${e.message}');}Subclasses: LinkSenseNotConfiguredException, LinkSenseInvalidSdkKeyException, LinkSenseNetworkException, LinkSenseDecodeFailureException, LinkSenseUnauthorizedException, LinkSenseForbiddenCrossScopeException, LinkSenseForbiddenFieldException, LinkSenseInvalidInputException (fieldErrors), LinkSenseNotFoundException, LinkSenseSlugExistsException, LinkSenseRateLimitedException (retryAfterSeconds), LinkSenseAccessDeniedException (upgradeRequired, plan, currentUsage, limit — your plan blocked the call, or the key isn't allowed on this platform), and LinkSenseServerException (code + status) for any other server code.
Example & Resources
The Flutter plugin repository includes an example app and the changelog. Questions about the preview? support@linksense.net.