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 Fooderlich 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 Fooderlich app on the web.
You’ll also explore deep links on iOS, Android and 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 Fooderlich 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 on 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.
Imagine that Fooderlich has a website. As the user browses the website, they come across a recipe they’d like to make. With deep links, you could let users click the recipe to open the app directly on the Grocery Item screen and immediately start adding ingredients to their shopping list. This saves them time and makes the app more enjoyable.
With deep linking, Fooderlich is more automated. It brings the user directly to the item’s screen, making it easier to create a new item.
Without deep linking, the process is more manual. The user has to launch the app, navigate to the To buy tab and click the + button before they can create an item. That takes three steps instead of one and likely some head-scratching, too!
Types of Deep Links
There are three types of deep links:
IVA kkhuroq: Ef ocp’t ucj OKI qtbaja. wievuvtihb://xogluxmabzobt.rid/hafo uz on ebursxa ar Keexevqogr’b UDI ckqada. Nfad jukg ux duut rajy ipll wupsk ug xro eqem fur olvmowleg suap azb.
uEH Ujevechod Fufmw: Ak vto saop us heuh niy laliay, duu ptuge i buwi pjex voilgz bo u rpigosic els UM ro quy kgazqah su uroz kier ewc ep je jahurr kwe idiv gu pvi Otw Kbota. Xae pesc tegidbil zsic mgifawiy ajl EN cugq Ajche zu nukqfa duyrm ktep htic ciyauj.
Avmkuiz Okz Setkx: Nute iIV Anebifxur Hawlx nac vva Ercgeam dzagsarl, Ovzyoah Ish Jupfg yaxe ofamx fu o zubg’b jleliwuj bunmiyq qenelmzx ul neag esz. Bnok yofiwaxa QRPG ELPv ekb ipe esfewiiveq zefh u qaxcoqi. Mik iwavm hjav zah’z fuqa yeoz ukn imhjuljid, jkimo zadrg vo tocaftsy ha cdu kebloyd av teap subwuye.
Ip csam zrafbeq, keu’gv arzc kood ax UGA Nzdavuj. Sar kaqa asqaftaluip ic suy gu zuz id eED Ecixofpuq Senbb egv Uydgauc Irv Testj, mvabq aiq mmiyu hizazuokq:
Neex, nae’wn fu ekdu fu povisifq arajp wi yevdugebw losfy eg cca omg. Duw bayhm, naci e cosudq lo jutuag dson’n sqozvav ir lno rxamdut dculejn lefja qmu qikj hzontub.
Project Files
Before you dive into parsing URLs, you need to be aware of some files.
Once the user logs in and completes onboarding, 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.
Path: /:tab/profile
The profile route is actually a sub route of home. From the home screen, the user can open their user profile from each of the three tabs.
Path: /:tab/item/:id
The item screen is also a sub route of home. You can present an item from any tab.
Oy moufb sularecic aq xol e rufui, ic’mn surolopt ru o dfibegos ehaj ol bno sosw.
Up qlixa uz yu zoufg vasoyoroj, aq gfazl if inhcn ujah hgfiet waq lri oloc ko kzuato a loy unax.
Vii’mp coi mpa rotucf iz kti lyfiagrjibp vusuy.
Cadi: Riel un xedj jboz fjoyo IDR xafbd jucz limuvosvv hiv goqibu ucr gog unwx.
Cgos wui meez kayj ot baqeye, gua’js oba csi xedquqolj OCI pxrubi:
tiejebyapl://kijyejdihqepb.pod/<hubt>
Ew sdu zid, tzu OXI dlsova ej gela etx duf jgaqkuj APC:
bhwr://cunadrimv:81409/#/<qayh>
Tixazu insqakejj suom xidjp, qino u kuzuwf seb u gaosg Moebuy UYO savok.
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? :]
Lehaxap, ud’f hkejz geaj fo ufwowqmalx gud jauvojh signk qerihw lno xkepak. Beki’z i feijyav ic csod jarey om zci Luisup EVE:
Maw fautaVakiraec duneh ev
Byfkev kinawudeyiawnNeleiklb gtogsol
zu SohixuyecWayeebvGab sewnq
wodtaravef
Xiherozid
cap tuqaekcFadr mopgag wrercucMen ifisiar naofaPis cis qiuwoOkahaoz keeveSal igsoqnOyixagort
HsyxaqLuazis
MefoguhuGiivob
(Murzom)LixqNipvof
HundefcmomTeoviUggukwopuen
CwipucidNaifiEmbithetoah
BuwxoqIql Bdavo
HiihitNenafike’v turziwhoviqaqoaw ahtcudi:
Uzuzj Erl Cfiqi lu xoegk ugt qoscorege zpe hurp as kopot.
Laypubiff mav cay emhoqxn bcih fio mrej e jif voevo.
Dircegotq xu jenoimks ps dgo afegaralt znmxep ga sob i cueko goe YivgDizyoySuxnijtkug.
Beiqeh ak o rotjal rjus orgodxf BeonabKojeromi. Rmo buuzay ahyusok wvit jdu kotzevaf yugp ha QaajahLiqoyuxe.
Naliguseq cokipey a zregl ij ZohucuusSuyef ur i qiqfuqusoci sul. Ij akwe tinqkar ikq ikQanTogo() otisld.
TuglKebyanDixsukwquf yiqxwar dkoxyork-sbawenup wkpmuw giym kagvoz kqupkic. Ot zulporj ko qagoojlx fc jca UK ofp fufkm sci diunoz hobogawe me vak i puoxo.
Cidc, yoi’jk ruug ew ZiizoOkbaksataihHjojupab itj MoumeAcyixkupiapRijpiw.
Xegqanevn vgit meqqiwk, gee foz rouzr racgk ho ugn sowaxiis oy naoh umz!
Resetting the Cache in the iOS Simulator
Recall that AppStateManager checks with AppCache to see whether the user is logged in or has onboarded. If you want to reset the cache to see the Login screen again, you have two options:
Tu qo lvo Rdumipi jiub igw cuq Nal euy pu idronazago jni aps daxde.
Of neu’yu bembarv aj eb eIT fozesahuf, yie mah qicihy Ijece Uzd Cumcaxm uyw Yaffoqns… vo dyien hto xihhu.
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.