Flutter Usage
Listen for links, read link data, handle deferred deep links and use the iOS paste widgets.
This documentation covers apliko_link 0.1.0 for Flutter.
Central Listener
Register one central listener at startup. It receives the one-time links (the link that started the app, a deferred link) and every runtime link. Screens that mount later read AplikoLink.getCurrentLink().
void main() {
WidgetsFlutterBinding.ensureInitialized();
AplikoLink.init('cl_live_…');
AplikoLink.addListener((url, data, meta) {
router.open(url, data);
});
runApp(const MyApp());
}One-time links go to a single listener because they start once-per-open actions such as navigation, onboarding or attribution. Two listeners acting on one link would navigate twice. See How Links Are Delivered.
Link source
The third argument tells you how the link arrived:
meta.source | Meaning |
|---|---|
LinkSource.initial | The link that started the app. |
LinkSource.runtime | A link opened while the app was running. |
LinkSource.deferred | The link tapped before installing, delivered on first launch (on Android possibly a later launch, see Deferred Links). |
Listening From a Widget
In a widget that listens for its own lifetime, register once in initState and remove the listener in dispose. Do not register in build or didUpdateWidget: a listener that re-registers moves to the back of the line, and a one-time link then goes to someone else.
class _ScreenState extends State<Screen> {
Unsubscribe? _stop;
void initState() {
super.initState();
_stop = AplikoLink.addListener((url, data, meta) => widget.onLink(url));
}
void dispose() {
_stop?.call();
super.dispose();
}
}Reading the current link
final CurrentLink? link = AplikoLink.getCurrentLink(); // url, data, source
final String? url = AplikoLink.getCurrentUrl();
// Takes the one-time launch link, so listeners will not get it:
final String? initial = await AplikoLink.getInitialUrlAsync();getCurrentLink() and getCurrentUrl() are never used up. getInitialUrl() returns null until startup has finished, so prefer getInitialUrlAsync().
Link data
final Map<String, dynamic> data =
await AplikoLink.getDataForUrl('https://acme.nvgt.link/abc123');For an Apliko link the SDK loads the link's data from Apliko with your client key, always over HTTPS, even for an http:// link, and returns it exactly as you set it up for the link. Anything that is not an Apliko link resolves to {}, and the key is never sent to any other host. The method never fails: if the link data can't be loaded, it resolves to {}, for example when the device is offline. See Troubleshooting if you get {} for an Apliko link.
Deferred Links
The link a user tapped before installing is delivered once, on the first launch of a fresh install (on Android a later launch if Google Play didn't answer in time), to one listener, with meta.source == LinkSource.deferred.
| Aspect | Android | iOS |
|---|---|---|
| Source | Google Play install referrer: the Apliko link page opens Google Play with referrer=<full link> | The user taps Apple's Paste button after the Apliko link page copied the link |
| Default | On | Off. Enable with EnableDeferred(ios: true) |
| The user sees | Nothing | Your paste UI; no permission prompt, because the tap is the consent |
| Needs | An install from Google Play | iOS 16+ |
AplikoLink.init('cl_live_…', enableDeferred: const EnableDeferred(ios: true));
// or EnableDeferred.all(true) / EnableDeferred.all(false)Rules on both platforms:
- Fresh installs only. An existing user who updates never gets an old link.
- Once per install, so it can never repeat.
- Apliko links only. The referrer or pasted text must be a full Apliko link, such as
https://<sub>.nvgt.link/…; anything else is ignored. - A regular link wins. If a link opened the first launch, or one is opened while the referrer is being read, that link is delivered and the deferred link is dropped.
- Startup is never blocked. If Google Play doesn't answer in time, the SDK tries again on a later launch, so the link can arrive on a later launch.
Read the outcome with AplikoLink.getDeferredLinkResult(), which returns url, data, source, referrer and isAplikoLink. Until the check has finished it returns the empty result: url is null and isAplikoLink is false. data is filled in only once the link has reached a listener.
iOS Paste Widgets
Opt in, then place the host once at the root of your app:
AplikoLink.init('cl_live_…', enableDeferred: const EnableDeferred(ios: true));
runApp(
WidgetsApp(
// …
builder: (context, child) => AplikoPasteHost(child: child),
),
);The host opens by itself on the first launch of a fresh install that was not opened by a link, when iOS says a link is on the clipboard. This is a silent check; the clipboard is not read. It shows a title, a message, Apple's own Paste button and "Not now". When the user pastes an Apliko link, it is delivered to your listener as deferred, every paste UI disappears, and the clipboard is cleared if nothing was copied since.
AplikoPasteHost | Default | Meaning |
|---|---|---|
child | — | Your app; the host draws over it. |
mode | AplikoPasteMode.auto | manual opens only through AplikoPaste.show() or the trigger. |
presentation | floating | A floating card or a bottom sheet. |
position | bottom | Floating only: top or bottom. |
title, message, dismissLabel | "Pick up where you left off", "Paste the link you copied to open it here.", "Not now" | An empty message is left out. |
trigger | none | A chip shown while there is something to offer and the host is closed: AplikoPasteTrigger(label: …, decoration: …, textStyle: …); only label is required. |
containerDecoration, titleStyle, messageStyle, dismissStyle | — | Look. Text styles are merged over the defaults. |
backdropColor | Color(0x5C000000) | Sheet only. |
pasteButton | — | AplikoPasteButtonOptions for the button inside. |
onLink, onInvalidContent, onDismiss | — | Callbacks. After onLink the host has closed; after onInvalidContent (something else was pasted) the host stays open. |
AplikoPasteButton is Apple's button on its own, for your own layout. Like the host, it renders nothing unless there is a paste offer right now: the first launch of a fresh install that was not opened by a link, with EnableDeferred(ios: true), on iOS 16 or later, while iOS reports a link on the clipboard. Its text, font and icon come from iOS.
AplikoPasteButton / AplikoPasteButtonOptions | Default | Meaning |
|---|---|---|
displayMode | iconAndLabel | AplikoPasteDisplayMode: iconAndLabel, iconOnly or labelOnly. |
cornerStyle | capsule | AplikoPasteCornerStyle: capsule, large, medium, small or fixed. |
backgroundColor, foregroundColor | iOS default | Colors. |
height | 48 | iOS draws the button into this height. |
width | as wide as its parent allows | Button only. |
onLink, onInvalidContent | — | Button only. An Apliko link was accepted, or something else was pasted. |
AplikoPaste.show() and AplikoPaste.hide() open and close every mounted host. show() also does nothing without an offer: the host still shows nothing.
All paste UI renders nothing on Android, web, desktop, iOS below 16, without the opt-in, and after a link was pasted.
By default the Apliko link page copies the full link on the user's tap before it opens the App Store, and on Android opens Google Play with referrer=<full link>. Only your own store links or landing pages must carry the full Apliko link themselves (copied before the App Store, or as the Play referrer), otherwise there is nothing to deliver. See your project in the Hub.
Platform Notes
Android: Back, Recents and cached engines
| The user | Result |
|---|---|
| taps a link while the app is in front | Delivered once, runtime |
| leaves with Home, comes back | Nothing |
| leaves with Back, taps a link | Delivered once: initial with a default FlutterActivity, runtime with a cached or shared engine |
| leaves with Back, opens the app from the launcher or Recents | Nothing |
| leaves with Home, Android ends the process, reopens from Recents | Nothing |
| changes a setting that makes Android re-create the Activity | Nothing |
Web
- The page URL is delivered once as the
initiallink. webRuntimeLinks: truealso reports Back/Forward and#fragmentchanges asruntimelinks, one per change. Off by default.- In an installed PWA, links handed to the open window are
runtimelinks.