Flutter
Add Vouch to a Flutter app. The plugin wraps the native iOS and Android SDKs.
Package not yet published
The plugin lives in the repository under sdks/flutter and can be added as a path or Git
dependency today. A pub.dev release follows.
The Flutter plugin is a thin bridge over the native SDKs. Matching, the offline event queue, the device identifier and exactly-once link delivery all run in Swift and Kotlin, so a Flutter app behaves identically to a native one.
Install
dependencies:
vouch: ^0.1.0You still complete the platform setup below, exactly as a native app would.
Add the applinks: entry for your Vouch domain to the Associated Domains capability:
applinks:yourapp.vouch.devInitialise and handle links
Your publishable key and app id are in the dashboard under Settings → API keys and Apps.
import 'package:vouch/vouch.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Vouch.configure(
publishableKey: 'pk_test_…',
appId: 'app_…',
environment: VouchEnvironment.test,
options: const VouchOptions(linkHosts: ['yourapp.vouch.dev']),
);
Vouch.onLink.listen((link) {
// Exactly once per link, cold or warm start.
router.go(link.destination, extra: link.params);
});
runApp(const MyApp());
}Once your router is mounted, tell the SDK it can deliver:
await Vouch.setReady(); // held links arrive nowIf you never call it, links are delivered after readyTimeoutMs, five seconds by default.
Deferred links
On the first open after an install, the native SDK reports the install and the server tries to
match it to an earlier click. A match arrives through Vouch.onLink with isDeferred == true:
Vouch.onLink.listen((link) {
if (link.isDeferred && link.isDeterministic) {
// installReferrer, clipboard or session: carried by a token, not inferred.
}
router.go(link.destination, extra: link.params);
});link.matchType is one of installReferrer, clipboard, session, probabilistic,
ambiguous or none. Ambiguous fingerprints deliver nothing rather than guessing.
To personalise onboarding before navigating, peek without consuming:
final pending = await Vouch.pendingLink();
if (pending != null) onboarding.preselect(pending.params['ref']);Events, identity and share links
await Vouch.identify('user_123');
await Vouch.track('checkout_completed', {'plan': 'pro'});
final link = await Vouch.createLink(
destination: '/invite',
params: {'ref': userId},
);
Share.share(link.url!);Events queue on device and are delivered in order with server-side deduplication, so calls are safe offline.
Referrals and device security
Planned API, not yet shipped
The calls below are the agreed shape of the SDK additions for Referrals and device security. They are not in a released SDK yet. The server endpoints they call are live, so you can drive both modules over HTTP today using the routes in those sections.
// A personal invite link and code for the signed-in user.
final invite = await Vouch.referrals.link();
share(invite.url, invite.code);
// Someone typing a code instead of following a link.
await Vouch.referrals.redeem('W3ZYEPD8');
// Attestation runs automatically; this is the manual trigger.
final verdict = await Vouch.security.attest();Verify
Run the example app in sdks/flutter/example on a physical device, then use the dashboard's
verification step. From an Android emulator, point the SDK at a local server with
VouchOptions(apiBaseUrl: 'http://10.0.2.2:8787').