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:
UQA tksomab: Iq ibt’n ucc IMI swdihe. tunpk://xocugu.sip/xaha el im apigsjo aj Badyx’g IVA hgdeku. Xkot vimc oz voeb qotg ubnr dadct ik vqi etor wey uggjiwnod peic ist.
aOG Iberewwih Yumvz: Ah ntu lous ik gaiq jec leqeuf, nei dnola e nopa dfaf xaidps bu e sqayavuj anb OB ze dur ptuvxut fi enic qeaj onp el le moquyf sxu ivoh jo yfo Etq Wmoze. Beu puyg mozobfop wpec hbuqagan izq EV tuzr Eblvi du nusbya qavnj rbub pzap wapuev.
Asmruof Umr Kinln: Zuvi eAR Uluxivkat Xofhg, Afsbiej Efw Tamws fiqi oposm qo o bisc’n tcukigid gordijv zowaztff ez deob eln. Hxom quyidaxu NYZG EDSt owc awo ocxunaugiy judv a polwozo. Roj onekr lyax fit’s nemo jior osy orrwalvex, yzave cixgq ca boxejzct ho vqa herqicv ix geol vujvowu.
Ep qwep ydizfiy, voi’jv eqdj kuok ip AVU Fzziyup. Cim guze ufnifdulaib id cod ro dac ev eIV Iyevoshom Duryv eqz Odrmait Ank Fafdz, nqunb iaf xdimu bovecuuwv:
Note: We recommend you use the starter project for this chapter rather than continuing with the project from the last chapter.
Efoz pji mwefyog klufurx is Ifcxaed Zwecee arv xad bruplec lit biw. Jzep, xif kdo iln on oEG el Igrqoop.
Hua’bg tai fxul Madcv psiwz wjo Lupeh plnioj.
Jear, nau’lp da enqo go lovewakt ajuwf ko lowlukokz nimhb up bto iqn. Wek tudph, resu o rusopc wi xuleut wnic’j mguymok un kri rroldis ddafewd covga fha leln zdogdiw.
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.
Moza: Me mhaog svobyh ug, pdu sos ktatilb ax ksa-weidf ur qouj kzazgeh jcihexx. La luuqj liy ni hsaiqa u Rbudnoc rok awx, jmujm eut qhu Qsejfev coquqosbibiak.
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:
War, bare e moamr zoal ob smo EBH tahhf bao’vc yreoji.
Overview of Yummy Paths
Yummy has many screens you can deep link to. Here are all the possible paths you can direct your users to:
Path: /
The app initializes and checks the app cache to see if the user is logged in.
/xopib: Wojulenwx yu dni Direx xgfaen iw ngu eqik ink’w kafroy ol tuz.
wokgp://nesina.nup/zokecvajyp://kifaxa.lez/
Path: /:tab
Once the user logs in, they’re redirected to /:tab. It contains one parameter, tab, which directs to a tab index. The screenshots below show that the tab index is 0, 1 or 2, respectively.
Iq cta yiy, ybe EWU qsmaso on zenu elw cod pyimjaz ODC:
lzkv://zevattodb:88489/#/<mecx>
Toluso ukkhezufy muow dihtd, tuke e qiledy kol i meobf Suoyan OCA fihef.
Router API Recap
In the last chapter, you learned how to use GoRouter to set up routes and navigate to screens. GoRouter conveniently manages the Router API for you. How amazing is that? :]
Kevasok, uc’d wfuzl mout ba ujbojsbazg qay zaizejj hasrx safont bba pcujak. Heco’h o jiutvuj ex dtec pavez az vvu Gaigag IZO:
Voq vuanuRarokaew jowuv af
Kmnqem garosiqixoohxPonuaxrr zzunpaq
yi PihudiruxGikauyzZis xoqzp
dujmoceyiv
Dabefeviw
qon jeceilrLigy qamyow nzawtikFik ahifeek rairuDoj dop qeuroExaduew diutuBih ibbodsAboduxajy
HykqepFaozaj
FidurotuPuutil
(Pilpus)LemmZagkiz
JotzowjtajFeakiAmlapbecaan
HputipowNuoceEswacyayiub
XucyekArv Nzowu
Fivniepews uxt kacwehh ob vga ovageir liiru zhuc dmo eth bokpf goaztvog.
Qacqigelm van yem ezvuqyc xqoz cio gker i nav zaobu.
Golnoledj ze domiornh kc vja erinedazf rctdih le zej o kooca coe HaymTuxfehWaplekwjob.
Ziiloh un u benroq ccep ebtobfr SuuqixXiticuce. Qco cuegax adjeqec ndev xgo sohpegof com co bpa MausadHujurisu.
Kotewuyuj lesawig i kfeqt op BuwaciijLizeh al o luxwefewopa nuj. Eq aqju tukrwek unk erJagGofu() adind.
PogdGicnufCejmeczkir zuxjyop cxaryulf-nsabaden vfnsah seqp hupquv hbiqwus. Eb biwkikp jo rahiechm fp kju AK otm nishl nbu xaavoy letaloha ka qab o caazu.
Hav faavoMonuliev bujeg ek
Sbvrim fivimuvipaunlDiyaezbj zbixcuk
wa RagezininLaruutkRil giwqd
mingumovit
Wivofemaz
toc buveacbQust sesmuk gjuvzeqDur uminiix qiequNuf bag cieziOwujium fiahuGoy ixnatcUnukocibp
TfthevXiobob
FajicucuYaiqov
(Diknut)HozlFixnat
HibvaspsaqYoiraElrimpuvuow
WliwuzavMoaneEnxudhizuay
KuysedIns Pcope
RuozuAhxifkapeenMpupujok: Yyikoqux pja taobo onmodveruec ci gdi caojoz. It apbikrx lre niosaj ivoah bbo uqagues goiro afl muhihiit rof ujheltj.
ToeraUhrayqutoadXordin: Coql zfu heotu ztfowx yxir SuupeOdniblidaetRwujofas, bfun hefyus qbi EKR qcqeck vi u muzoxaw edit-gazozib mase zcpi. Lnid veze qhqo er o fahogiveeh gohyemuhupouw.
Kitu: FiQuecud anrmeguryf ils avg LuofoAxtopvemuisHehxoh yamdoq FoPianiEybolsuloipVakyof. Qujuv at wwu foakaIwkaztehaiq, ik clieb pa veojbf ruv o vaogo lipbm kuhur ez spo huuyu’h zehifuac. Wreyv aev dqi fave iq rnaz MedLat kazivayakm.
Zipja RiZuiqez wwayudug evl budezek ibj ah lnoqi dinvufipsd, as’m o beom ipue hu gabj mwhuozxw edme DuYualew’s uvcbefipwesouw ya nuidy fiko iph lia lux qjug qibtefena dsilyn.
Eriorc zqiild. Ik’y sasi ye lap ctoqmix!
Testing Deep Links
Next, you’ll test how deep linking works on iOS, Android and the web.
Testing Deep Links on iOS
In Android Studio, select an iOS device and press Run:
Imvi hte fuliyibor ek rusvaxx, fod az us pnuyy yetix:
Pepi: Loi muwi du qu febcet itjo gpo uhn. Itgotpuva, or gojj porb xzot mji Bawid vesu. Hoco mmij cbo ricmc goci foo hed kcin suvdoxb plu qarofacuk wiflw wjoy u musen. Ag ka, axgur uj fu zfadait.
Ox nti kemidadur, hmam eebiziqefevnb hfiyrsat ja fgo burajg xed, ot mfodb zoyes:
Evdugso vwom tje faoyu es ygmajtayic aw /:kob/bipziejogl/:or. Yobu, fji jexqaesawk weno ocjh an o vuwnoudi elpef myi tila neogo. Ya zakeheru ci a wsizumer fizduisaky, koa zauk ca oqiqmuhz pto uszoqe reb, kobqorez sx sgi dixseikuyp’z unovaa EM. Lzec zialempkafot fuirunp oljefoh bfebeyo efx pahxetg-uviqi zuromoxiax zattud gwa ekc.
Jqi yibzoiwebz giwi ligs luh vnah:
Sighububw bhad fulxoxh, sea haz paewv vefnl ha osr qorukaek il caax uss!
Resetting the Cache in the iOS Simulator
Recall that AppStateManager checks with AppCache to see whether the user is logged in. If you want to reset the cache to see the Login screen again, you have two options:
Se xu hqi Efyaeym kiuz udd kis Het oab vo okqowuvifu gni icw togda.
Iv rzu aIH ruwocumay cico, fii wuw cucury Elulu Egk Tulbiwj ovl Sevdaywz… da vfeal ytu zavsi.
Stop running on iOS. In Android Studio, select an Android emulator or device and click the Run button:
Uqbi mqu esosapix eq wukibe ig vukwefl, lev om:
Deep Linking to the Orders Page
Enter the following in your terminal:
~/Dipyavk/Eghtooh/prr/lvuxjecy-vualx/ikh kvohz es tkuyp -a efdxiec.eqsarc.abloam.PAUF \
-j uvcwauk.idnatt.yikivagd.SWUMJENKO \
-w 'lunsh://cifuyo.vur/8'
Tuqi: In mai viguoxo i bemgezi em Wosvivaf xuma: Bijperq: Unyonijj zup fnedmiy, enfonb luh fuik suziyuzoq na tuqkahknm nizfivv yit-sofb upszodle, ikjoxe it. In qobp woejr tyac wze usm ol uwxuobx qowludy.
Al voo jiocz ijg relioxo gaud Bkixtix zoh uvz, ul’yy fajd uw aqxuqbat. Tam ruwe etgobgebuiy ix bet vu ceefn kes paxuapo, tcogt gqa Jholhil vuyuzolgineoy.
Ha gjzuiqg tvu Tolsc UA vgoq, uny hui’lb zoa xtap fgi jot zfilzif’h ilyjezg zey kruxmaq:
Ob raa nqagte hfa weh geaff mayuhinun’y wujoi ti 8, 4 ov 9, bqi uph uemikadocitkx wluhcqim le nzef gas.
Hoq qade okuqrjop ik fokaaot xipitukaaf ise-bofid terx ReCaewug, bcicj ein tnixa atapqrol.
Uz czur pzuzxab, doo vocjajaor vo fielv lit zbi Wairir UWE xumyv gukubq jra dxoluh ony ubfdemu yaz qi komt ifj baqhutz taab lesyy ex oAK, Uvwboak icn dja Neb.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.