Flutter SDK reference
Everything in strait_sdk 0.10.9, in one place.
On this page 5
StraitLinks(...)
| Parameter | Type | Notes |
|---|---|---|
publishableKey |
String |
Required. st_pub_live_… |
endpoint |
String |
Required. Your link domain, https://<handle>.strait.link |
platform |
String |
Required. 'ios', 'android' or 'other' |
deviceFields |
DeviceFields Function() |
Required. Screen width, pixel ratio, language, IANA time zone (see Install & set up) |
storage |
KeyValueStore |
Persists the once-per-install flag and unsent reports. Defaults to memory only |
installReferrer |
Future<String?> Function() |
Android: the Play Install Referrer string |
installTime |
Future<int?> Function() |
The app's install time, epoch ms: () async => (await PackageInfo.fromPlatform()).installTime?.millisecondsSinceEpoch (package_info_plus 8.1+). A reinstall from a link runs the deferred check again, even after a backup restores the app's storage. An app update doesn't |
appVersion |
String |
Your app's version, sent with each open and install report (with the SDK's own version) so support can see which build opened a link: (await PackageInfo.fromPlatform()).version |
linkHosts |
List<String> |
Extra hosts that serve your links |
clipboardBoost |
bool |
Deprecated, ignored. Paste handoff is switched on in the dashboard and read from the server on first launch. See How iPhone install matching works |
clipboard |
StraitClipboard |
hasProbableWebUrl() and readText(), used only when your workspace has paste handoff on |
Methods and streams
| Member | What it does |
|---|---|
start({initialUrl, urls, lifecycle}) |
Handles the launch link, listens to later ones and the lifecycle, runs the deferred check once |
onLink |
Stream<LinkEvent>. Replays past events to late listeners |
onLinkStart |
Stream<LinkStart>: a link arrived and is being resolved |
handleUrl(url) |
Hands the SDK a URL yourself |
trackEvent(name, {value, currency, linkId, clickId, eventId}) |
Records an event; true when accepted. eventId is your order id, counted once; left out, the SDK makes one. An event it can't send (offline, server busy) is kept and sent later |
checkDeferred() |
Re-runs the deferred check (debugging). Never records an install |
claimHandoff(text) |
Claims a clipboard-boost link your app got itself |
pendingOpenReports() / flushOpenReports() |
Count, or send now, the open reports and events saved while offline or while the server was busy |
setEnabled(enabled) / isEnabled() |
Opt-out switch for consent flows (see below). Kept in your storage across launches; default on |
setUserId(id) |
Your own user id for later events' app.event webhooks (userId); null on sign-out. Memory only; emails and phone numbers are hashed on the device (how) |
stop() / dispose() |
Stop listening; dispose also closes the streams |
The link event
| Field | Meaning |
|---|---|
kind |
LinkKind.direct (a link opened the app) or LinkKind.deferred (tapped before install) |
route |
app_link, custom_scheme, install_referrer, fingerprint or clipboard (route.value) |
appState |
closed, background or foreground |
matched, reason |
When matched is false: not_found, expired, password_protected, no_match, network, invalid_url |
rawUrl |
The URL the OS handed the app |
url, path, params |
The destination to navigate to |
linkId |
The id of the Strait link |
id |
This open's id (not the link's), shared with its onLinkStart signal |
ms, at |
Resolve time in milliseconds, and arrival time (epoch milliseconds) |
User consent (opt-out)
If your app asks for consent first (for example under India's DPDP Act or a GDPR consent flow in the EU), call await links.setEnabled(false) until the person agrees: Strait then sends no open reports or events, does no install matching, and deletes reports waiting on the device. The choice is kept across launches in your storage; setEnabled(true) turns it back on and isEnabled() reads it. A Strait short link still opens the right screen: it is looked up without recording a tap, an open or a tap id. The legacy resolveDeferredLink honours the same switch when you pass it the same storage. Whether you need consent, and for what, is a question for your own legal advice.
Deferred match only
final result = await resolveDeferredLink(
publishableKey: 'st_pub_live_…',
endpoint: 'https://hilltop.strait.link',
platform: Platform.isIOS ? 'ios' : 'android',
device: device, // DeviceFields as in Install & set up
installReferrer: referrer, // Android only; null otherwise
);
if (result.matched && result.longUrl != null) { /* route */ }It never throws; on any error it returns MatchResult.none.