Sub topic 1
What a Deep Link Is and Where It Is Used
A deep link is a URL that opens a specific location inside an app. A normal app launch opens the home screen. A deep link can open a product, article, order, or account screen directly.
This chapter assumes you know basic Dart and Flutter widgets, understand URL parts such as paths and queries, and can run an app on an emulator or device. You should also be familiar with Flutter navigation. You do not need to know platform link configuration yet.
Prerequisites
Before working with deep links, make sure you can:
- Build and run a Flutter application.
- Navigate between Flutter screens.
- Read a URL such as
https://example.com/products/42?ref=email. - Run commands on an Android emulator or iOS simulator.
- Access a web domain if you plan to configure verified links.
Why Deep Links Matter
Deep links connect an outside action to a useful screen in your app. A user might tap a product link in an email, select an invitation in a chat, or open a payment link from a notification. The app should preserve that context instead of making the user search again.
For example, an online store might use these links:
| Link | Destination |
|---|---|
| `https://shop.example/products/42` | Product 42 |
| `https://shop.example/orders/81` | Order 81 |
| `https://shop.example/invite/abc` | Invitation `abc` |
The link contains data that the app uses to choose a screen. The value 42 is a path parameter. A value such as ref=email is a query parameter.
How a Link Reaches a Screen
The complete flow has several parts:
The operating system first decides whether an installed app can handle the URL. Flutter then receives the URI, which is the structured representation of the link. A router matches the URI against route patterns and builds the correct screen.
The app must handle both startup situations:
- A cold start happens when the app is not running and the link launches it.
- A warm start happens when the app is already running and receives a new link.
A reliable implementation treats both cases as normal input. It should not assume that a link always arrives after the first screen has finished building.
Link Types
A custom URL scheme uses an app-specific prefix, such as myshop://products/42. It is easy to create, but another app could register the same scheme. The operating system may then ask the user which app should open it.
A verified HTTPS link uses a normal web address, such as https://shop.example/products/42. Android App Links and iOS Universal Links use files hosted on the domain to prove that the domain authorizes the app. This gives users a smoother and safer experience, while requiring platform configuration.
What This Tutorial Builds
You will connect three layers:
- The platform configuration that delivers a link to the app.
- Dart and Flutter code that parses and routes the URI.
- Validation and fallback behavior for missing, unknown, or unsafe values.
The same design also applies to Flutter web, where the browser URL directly represents the current route. Deferred deep links add another case: a user taps a link, installs the app, and reaches the intended content after installation.
Exercise
A user taps https://shop.example/products/42?ref=email. What should the app use to select the screen, and what information should it preserve?
Show answer
It should use the path /products/42 to select the product screen, extract 42 as the product identifier, and preserve ref=email as the query parameter.