Flutter SDK
Install and initialise
Add becklinks_flutter, configure it and receive links.
becklinks_flutter is the Flutter plugin for Android and iOS. It opens the right screen for a link,
delivers the destination after an install, reports attribution and sends your events. It has no
native code to add: you only do the platform setup (Android,
iOS).
The package was called becklink_flutter up to version 0.2.1. If your app still uses the old name, change
the dependency to becklinks_flutter: ^0.3.0 and the import to
package:becklinks_flutter/becklinks_flutter.dart; nothing else changes. The old package only re-exports
the new one, so it keeps working until you do.
Get it: becklinks_flutter on pub.dev · API reference · Changelog · All versions
Requirements#
| What | Minimum |
|---|---|
| Flutter and Dart | Flutter 3.27 (Dart 3.6) |
| iOS | iOS 15, Xcode 16 or newer |
| Android | Android 6.0 (API 23), compileSdk 35 |
| Beck Links | A project with your app configured and its publishable key |
Install#
flutter pub add becklinks_flutterConfigure once, route in one place#
import 'package:becklinks_flutter/becklinks_flutter.dart';
import 'package:flutter/material.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Returns at once; storage, the launch link and network work run in the background.
await BeckLink.instance.configure(apiKey: 'pk_test_YOUR_KEY');
// The one place that routes links: the link that launched the app, the deferred link after an
// install and links opened while the app runs. Each arrives once.
BeckLink.instance.onLink.listen(routeLink);
runApp(const MyApp());
}
void routeLink(LinkEvent link) {
// link.path the screen to open, such as /product/123
// link.params query parameters and, for links of an item pattern, the item (link.resource)
// link.data the custom JSON you set on the link
}onLink keeps the newest links until the first listener subscribes, so nothing is lost between
configure() and listen(). Use pk_test_… while developing and pk_live_… in release builds.
For links that survive an install on iPhone, also pass enablePasteboard: true to configure(); it is off in code by default (see Deferred deep linking). Android needs nothing extra.
What a LinkEvent tells you#
| Field | Meaning |
|---|---|
url, path | The link and the in-app route to open |
params | Query parameters of the opened URL; for a deferred link, the ones your link allows to pass through |
data | The custom JSON of the link |
isDeferred | true when the link was kept through an install |
matchMethod, confidence | How the link was matched (app_link, install_referrer, pasteboard, …) and how sure that is |
linkId, campaign, clickedAt | Which link and campaign it came from |
resource | For links of an item pattern: the item (type and id); otherwise null |
Attribution and events#
final attribution = await BeckLink.instance.getAttribution();
await BeckLink.instance.setUserId('user_8841'); // after sign-in; use an internal ID
await BeckLink.instance.track('add_to_cart', properties: {'sku': 'SKU-123', 'quantity': 2});
await BeckLink.instance.track('purchase', revenue: 49.98, currency: 'USD');See Attribution and events for names, limits and what is sent.
Consent and privacy#
The SDK uses no advertising ID, no device fingerprinting and shows no tracking prompt. To wait for
consent, call setTrackingEnabled(userHasConsented) right after configure(). While tracking is off,
links still open and route, but no first open, sessions or events are sent.
Verify it works#
- Run a debug build with
configure(apiKey: …, logLevel: LogLevel.debug). - Open a test link on the phone (Notes or Messages on iOS; on Android,
adb shell am start -W -a android.intent.action.VIEW -d "https://acme-test.becklinks.com/abc123" com.acme.shop). - The console shows
[BeckLink] INFO: Delivering LinkEvent(…)and the app opens the linked screen.
The package page on pub.dev has the README, the API reference and the changelog. Next: Handle links in your app.