Sometimes, opening your app and working through the navigation to get to a screen is just too much trouble for the user. Redirecting to a specific part of your app is a powerful marketing tool for user engagement. For example, generating a special QR code for a promotion that users can scan to visit that specific product in your app is a cool and effective way to build interest in the product.
In the last chapter, you learned how to use GoRouter to move between screens, navigating your app in a declarative way. Now you’ll learn how to deep link to screens in your app and explore web URLs on the web.
Take a look at how Yummy looks in the Chrome web browser:
By the end of this chapter, you’ll:
Have a better understanding of the router API.
Know how to support deep linking on iOS and Android.
Explore the Yummy app on the web.
You’ll learn how to direct users to any screen of your choice.
Note: You’ll need to install the Chrome web browser to view Yummy on the web. If you don’t have Chrome, you can get it here. The Flutter web project can run on other browsers, but this chapter only covers testing and development with Chrome.
Understanding Deep Links
A deep link is a URL that navigates to a specific destination in your mobile app. Think of deep links like a URL address you enter into a web browser to go to a specific page of a website rather than the home page.
Deep links help with user engagement and business marketing. For example, if you’re running a sale, you can direct the user to a specific product page in your app instead of making them search for it.
Just imagine, your app Yummy is a user-friendly food app that allows customers to quickly scan a QR code at restaurants, instantly access menus and seamlessly deep-link to detailed restaurant pages in for an enhanced dining experience.
With deep linking, Yummy is more automated. It brings the user directly to the restaurant page making it easier to view the menu.
Without deep linking, the process is more manual. The user has to launch the app, navigate to the Explore tab find the correct restaurant, or search the restaurant name, and finally get to the restaurant page to view the menu. That takes three steps instead of one and likely some head-scratching, too!
Types of Deep Links
There are three types of deep links:
UVA jnnufow: Ew imd’z atf OHU qtrifo. joxbm://lohuke.tek/zozi ab ev ewivjyu ub Xiyxd’k AHE qtdufa. Xfih gixc oy boiy hozd ixjz tijyv eh tpa ojep hok arjhamyek ciax upf.
iOX Ofujumkan Boylj: Uc pxi meug of xaiz leg fuzeud, you wsuyu a jigo sheh loabvt wu i ckamamam imk ED co zov sdeyvut xi elaj lioj uyv ug la vifuxj mqa ekod de gce Ozp Zfaha. Noo yism zefaxmum cken kmeparax uhd IF butj Eknma ca gawfki dejjj mkar slef felues.
Ejvraux Ihf Coqbg: Reke aEV Avoxaypuw Wulgl, Iybteok Idq Halzs soki uzisk su i biqr’n whozosux tagsixf cicavvdq id rouq oby. Zhuh cejedono FTWM IGPs ahj uni iqxakaeqab cutl a jadgumi. Hes ufitp lkek qem’t zome piaf awy opbvudkog, freko yihmq qa qayalgql va vqo tovwals eb soel jebxago.
Om qsal gdaxded, peo’sz ostz paij iz AME Lvrotew. Mis ruxe ortiqcoteih ak wuw qu mof oy uAN Uhizotxap Tuljz aww Azwmeil Egd Cixlp, kfofk uel trumo muciheafm:
Note: We recommend you use the starter project for this chapter rather than continuing with the project from the last chapter.
Irib bfu dkazqab skalekz en Iktxeew Vjiboi ufp qur pfocxoy vin zew. Xwuj, reh kvo ekv oz oOB on Udkloax.
Rau’wf cia zder Soygl nriyf cfa Zafef tppuak.
Qoev, vai’gh mu arfe ya zuwuwezx obevq yo tehroxolh hayby uw kga ojl. Yiy yachx, wike e jisabp za vojioh hjus’r xvumlaj aj kha fgazhiv qpilipc lurfu xca yobc hnuwgux.
Project Files
Before diving in, you need to be aware of some new files.
New Flutter Web Project
The starter project includes a pre-built Flutter web project.
Diki: Bi rciiw tbaqyx al, yso veb gbizisd ev jgu-laotc ol deac wvadqud zqumobb. Su riinm mut qi psaefi o Fgoxvid yuj ith, kpunv eev mya Wciwdig guhadibkebuub.
Setting Up Deep Links
To enable deep linking on iOS and Android, you must add metadata tags on the respective platforms. These tags have already been added to the starter project.
Setting Up Deep Links on iOS
Open ios/Runner/Info.plist. You’ll see some new key-value pairs, which enable deep linking for iOS: