Deep linking in Flutter, end to end
Flutter can route a link to a screen, but a working deep link also needs two verification files on your domain, one setting per platform, and something that remembers the link across an install. Beck Links hosts the files and handles the install and the reporting.
Updated · by Tecbeck, the company behind Beck Links
What a deep link needs#
A link that opens your Flutter app on the right screen needs four things. Flutter does one of them.
| Need | Android | iOS | Who does it |
|---|---|---|---|
| A verified link type | App Links | Universal Links | The operating system, once your domain proves it owns the app |
| A file on your domain that proves it | /.well-known/assetlinks.json with your package name and signing fingerprints | /.well-known/apple-app-site-association with your team ID and bundle ID | You, or a link service that hosts it |
| An app setting that claims the domain | An intent filter with autoVerify in the manifest | The Associated Domains entitlement | You, once per app |
| Code that turns the incoming link into a screen | A link listener and your router | The same | Flutter plus your router |
The first and fourth are the easy part. Most failed links are a mismatch in the second or third: a wrong fingerprint, a file served with a redirect, a missing entitlement.
What is still missing after that#
- Installs. If the app is not installed, the link opens a store page and the context is lost. Remembering the destination across the install is a separate piece of work, described in what deferred deep linking is.
- Data. Without a service you do not know how many people clicked, installed and opened, or which link did it.
- Previews. Chat apps show a card for a link; a link to a product looks better with that product's title and image.
What Beck Links adds#
You describe your Android and iOS apps in a project. Beck Links hosts both verification files, serves your links on yourproject.becklinks.com, remembers the destination across an install, and shows clicks, installs, first opens and your own events. In the app there is one call and one listener:
await BeckLink.instance.configure(
apiKey: 'pk_live_YOUR_KEY',
);
BeckLink.instance.onLink.listen((link) {
// link.path /product/123
// link.params ?ref=emma
router.go(link.path);
});The listener works with go_router, Navigator or your own code, because it only hands you a path and its parameters.
Check it before you ship#
A project has a test environment with its own link host and keys, and a Link Tester that shows where each kind of device would be sent for a link you made: the app, the store, the web page, or a QR code on a desktop. The docs cover the platform setup step by step: Android, iOS and the Flutter SDK.
Questions people ask
- What are App Links and Universal Links?
- They are the verified kinds of deep link: Android App Links and iOS Universal Links. The operating system checks a file on your domain (assetlinks.json on Android, apple-app-site-association on iOS) and, if it matches your app, opens the app directly without a chooser.
- Does Flutter handle deep links by itself?
- Flutter delivers the incoming link to your app and can route it with the router. It does not host the verification files, remember a link across an install, or measure clicks and installs; that is the part a link service adds.
- Which router should I use?
- Any. The SDK hands you the path and parameters of a link, and you give them to go_router, Navigator or your own code. Nothing in the SDK depends on a particular router.
- Can I test links before going live?
- Yes. Every project has a test environment with its own link host and keys, and a Link Tester that shows where each kind of device would be sent.