Set up your app
Flutter
Set up DL2App deep links in a Flutter app: native host setup, configure, and the links stream.
1. Native setup
Flutter apps declare link hosts in the native projects, exactly as native apps do:
ios/Runner: add the Associated Domains entries from the iOS page.android/app/src/main/AndroidManifest.xml: add the intent filter from the Android page, and enter your signing fingerprints in the dashboard.
2. Configure and listen
import 'package:dl2app/dl2app.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await DL2.configure(
'pk_live_xxx',
options: const DL2Options(
linkDomains: ['myapp.dl2.app', 'myapp-alt.dl2.app', 'go.myapp.com'],
),
);
DL2.links.listen((link) {
// link.path, link.data, link.source
router.go(link.path, extra: link.data);
});
runApp(const MyApp());
}DL2.links carries direct links and the deferred link after an install. DL2.initialLink() returns the link that opened the app, if any, and DL2.track(name, value:, currency:, props:) reports an event.
What the SDK does for you
- Delivers one event for all three cases: a link that cold-starts the app, a link while it is running, and a deferred link on first launch.
- Queues links that arrive before your listener is registered, so a cold-start link is never lost.
- Falls back to the URL’s own path and query if our API cannot be reached within 3 seconds, so the app still navigates.
- Never throws into your app: errors go to an
onErrorcallback. - Reads no advertising identifier. See Privacy and App Store disclosure.