Flutter in five steps
The shortest path to a working Flutter integration. Every step is the minimum that works, with no options. For anything beyond that, each step links to the Flutter SDK reference, which is where the detail lives.
1. Install
Section titled “1. Install”dependencies: tolinku: ^0.8.1 app_links: ^7.0.0flutter pub getapp_links is not bundled with this SDK. You need it to receive incoming
links, and it is yours to upgrade.
2. Set up Universal Links and App Links
Section titled “2. Set up Universal Links and App Links”Both platforms need native configuration: Universal Links (iOS) and App Links (Android). Neither is done by adding the package.
3. Configure
Section titled “3. Configure”import 'package:tolinku/tolinku.dart';
void main() { WidgetsFlutterBinding.ensureInitialized();
Tolinku.configure(apiKey: 'tolk_pub_your_key'); runApp(MyApp());}Keep ensureInitialized(). Without it the SDK cannot watch for your app
leaving the foreground, so queued events are lost if the system kills the
process.
Get the key from the dashboard under API keys. The publishable key
(tolk_pub_) is the right one for an app.
4. Claim the deferred link on first launch
Section titled “4. Claim the deferred link on first launch”This is what recovers the link somebody tapped before they had your app.
final link = await Tolinku.instance.deferred.claimDeferredLink( appspaceId: '64f0a1b2c3d4e5f60718',);if (link != null) { // Route to link.deepLinkPath, then step 5.}Call it once, on the first launch after install. The claim is spent the first time it succeeds. One call covers both platforms.
appspaceId is the Appspace ID from Settings, not your subdomain. Passing
the subdomain makes every call return null. See
finding your Appspace ID.
5. Report the open
Section titled “5. Report the open”Two calls, and they are not the same event.
An ordinary open arrives in two places, and both need reporting:
import 'package:app_links/app_links.dart';
final appLinks = AppLinks();
final initial = await appLinks.getInitialLink();if (initial != null) { Tolinku.instance.trackLinkOpen(initial.toString());}
appLinks.uriLinkStream.listen((uri) { Tolinku.instance.trackLinkOpen(uri.toString());});On app_links 5.x and earlier that first call was named getInitialAppLink.
The open that follows the claim in step 4, which is the last step of the install funnel:
final url = link.url;if (url != null) { await Tolinku.instance.trackLinkOpen(url, deferred: true);}Report link.url, never the path. A path is dropped before it leaves the SDK,
silently. This needs SDK 0.8.1 or later.
Whether these are counted, and what they cost, is an Appspace setting: Attributing app opens.
That is a working integration. For referrals, in-app messages, ecommerce events, custom events and every option on the calls above, go to the Flutter SDK reference.