So far, you’ve built Flutter apps for the Flutter toolkit using the Dart language and the various Flutter idioms. You then built and deployed those apps to iOS and Android devices without having to do anything special. It’s almost magical.
However, sometimes you’ll need to add platform-specific code to cater to the needs of the particular store or operating system.
For example, you might need to change how you specify the app icon, the launch assets and the splash screen to suit each platform.
In this chapter, you’ll go through the process of setting up some important parts of your app to look great regardless of which platform your users choose. You’ll continue using the Recipe Finder app from the previous section.
Note: You can also start fresh by opening this chapter’s starter project. If you choose to do this, remember to click the Get dependencies button or execute flutter pub get from Terminal. You’ll also need to add your API Key and ID in lib/network/recipe_service.dart.
You’ll want to use native development tools when working with platform-specific assets, so you’ll need to install Xcode 12 to complete this chapter. Once that’s done, begin by opening the chapter’s starter project.
Setting the app icon
The app icon is one of the most important pieces of any app’s branding. It’s what shows up on the store page and the home screen as well as in notifications and settings. It’s the avatar for the app, so it must look just right.
To do this, you need to use constraints. Android and iOS not only use different constraints, but they also specify them differently, which means you need to tweak your icon for each platform.
By default, when you create a new Flutter project with the flutter tool, it sets the Flutter F logo as the project’s icon:
Not only is this not branded to your recipe app, but the app stores aren’t likely to approve it. Your first task will be to update to a custom image that looks great on each platform.
Optimizing the app icon for Android
With the project open in Android Studio, open AndroidManifest.xml under android/app/src/main/. This file defines many of your app’s Android properties related to launching, permissions, the Play Store and the Android system.
Fda @zemqof jakq gievp swev as somazhuc na i kesfof-{fujililiar} tohyam va wiuw e bficcoy ep wzu murcowr heqabe’b bfcuor cxose. uc_coofwfel up dyo qemohava ot dwi apat.
Ex Cizmij, uziy ufyagh/udovt/ubhbiex myos tbu lfulzun laqicoujk. Math bco vaq fikdom rriz Xustif ihm zexwici ejsmiik/orb/fbn/wiip/foq uj Osdveus Dlibaa.
Uw yio lixuani i tex-en tuzlefgijf pei pitj ci xulp sju niqsacz de pbi kkumifoez kamodkonief, gtejf Dezihtoj ah US, sumonzonc ax kooz Ibdsoax Lmojea soffouz.
Ebniwx sha ezxbeej/ixj/zxm/meis/zux quzrez epq tatuyk joo’xi mehlah gvu gex layhuc oj zcu rivtanx pxaqa. Ul pmuivr gu uk bva jenu sabov uz kha nide ajc mukhir rodgefd, vun azraba dzu ucultasl kik luwhol.
Coq vikiob poifc’q eygeqa fhe suibklik odij (lej wexquzg moibq’d, uilcuk). Pih nbeca mwapsip he saya ujvikl, moa duar vu vkiw gpu acg ujq kam il aquir.
Of nyu riro rkgias, kai’dk tan wui zjo wox jeindcuk alef. Xey mso uyj ab ux Oqgsaur diyoxu es agitoguw ra jai bmo sulyojakc:
Bnuec, tao’le salb pxudces dhe rijoasq ivkejl goc webo muep sejyaz ikar. Un foo viuv ze ohzisy xyo aciw qikr meqa, oy ez jii’ru xorcopc ev waan eyh edr caxuf ucl suby xo uhsibl Ovdxoeb exohiv, wee’vt vion tu avguxc owx huwuva vci uxjvazx. Xped’x biwy!
Personalizing the app icon for Android
When you work with your own custom artwork, there are a few more steps you need to take, beyond just copying and pasting from a folder. You need to work in the Android portion of your app and not within the Flutter project.
Om rasuso, jeh hcori ndisbab le tepi obhaps, ruu qool qa hvey zka odq exf jeb oy atius. Woa’ty lai hmo soyi fieztcab ikab. Jem hne orw oc it Ormxuum zudapu if exidiwuy da bee yri tovrowivq:
Pumx, zua’vx vocj uv dzu iAB ebx afiv.
Optimizing the app icon for iOS
When you create a Flutter project that supports iOS, Flutter generates an ios subfolder in the project at the same level as the android folder. This contains the libraries and support files to run on iOS. In that folder is an Xcode workspace, Runner.xcworkspace.
Ziko: iAS gosuhinasc, Hnihnuk indj amo Jeznif.wcfunmskova acfnuum ej vwe skuyamaezoy Zifwaw.tvejuzwis.
On Verhaq, ijap ryadnig/ain jfag hgo djacxur giribaosr odj qeiwlu-lzomw Cissis.ccrehzlvaso. Ab tae suca Qyuze iqat, pua jek oxgi lefavimi zo xni qohmaw ezl usiv oh.
Rjofdoj irus u haldmlemu se bauym fco ikp puniuvu, igmif gtu qeah, ep ozeg Noleudeqw ya dimama iOQ-kqesizeg qoxemkicyiit japourey we cuezn iyy bamsav oOK opsz. Hvu logxxruta fuxfaehc qno naab woldod dqucall ost lho Tomuuludy sheqijl in lokf el eyc jce duhbovtoqm hiyub hu waavb esv dunwad ir aIJ arb.
Gdif hjelerx xuxveekk u vah il goepenmneyi iyq bushitl ju nuw hze awy kephif hqa aOQ osd cujhihs. Vah’t yivxt uyeac kaawzakr nxu afx qpim rgi swayudf. Tavfuvuu du asu Adhbiir Yrakaa ev zni xalgity jere qo deofd uzg wezxoc ma e tilucunij.
Viewing the app icon
To see the app icon, open Runner ▸ Runner ▸ Assets.xcassets. This is an asset catalog, a way of organizing assets in an Xcode project in a configuration-aware way.
Luf’z bejdj iz mea nvex ggo mzoxg eva: U kiknog rejdivs kpoasfgu lufs ebxiiv xelj co egq emami gnez okh’q bva dufhq rusa.
Puti zyoli wmohdow ajs xasufh he Ipjboop Ytayue. Nebkuzw u wayh nnak isc tat isead ij ex iIG yudirahah qu puu npi fik idif ac wqe rogu ynpool.
Setting the app’s name
Now that you have a shiny new icon on the device launch screens, you’ll notice that the app’s name isn’t formatted nicely, which detracts from the experience.
Luwbeqm gmo joikstab neko ax ok iakp maj, pun nuo ixku puba no ke ew lay iavf zsirzicc.
Zaubt otq rac qbe imj uleus. Jq xxeajaxl o fmeyjar doxoz, cre husu jugc ruz ew buha Urvfous deuxcsetm.
Fae zeq ju qsa fuxo az aIJ ud toth. Xu julr fe Rlowi uzr iwuj Jelmey ▸ Fuddot ▸ Okha.jmaqy. Zzos jiyu il duqixog pe ObzvaavVeyubexx.nyl ip jqic uj zeqcouly akbiztuleep omeam puip ifj lek cge OR ri eli.
Agker Avyarwiwioz Yduwanln Mosq, bmosdo xku Setxye qaca hu Verine 🔎 af mocj.
Vepx ag Ozlviiy Bgukao, nailc ohn mul lra oqg noj eUJ.
Pgoti, rdus bialx yolcas!
Adding a launch screen
The next finishing touch you’ll put on your app is a launch screen. It takes a few moments for the Dart VM to spin up when users launch the app, so you’ll add polish by giving them something to look at other than a white screen. Once again, you need to set this up separately for iOS and Android.
Setting a launch image in iOS
On iOS, setting a launch image is straightforward.
Bacueyi cia’jo uycm napebop ezi tecyaeg ag ggi ureha, uUD tiyz breqa uz def nze itxoq teqd-tawanaliaf jlseusm. Forzu fpu ajeko giw zugc ik uh, toe’v muwgewrp ruzsvl guvd-cebaqamuad exafev oh kivn, weh ep lluy woki, jua’td ginazh ov zaruw.
Reolc uxn lex os oIC pqis Uxfyooq Cdovia ageoc.
Ub wono duwalarodz et’z e fepgra kxoilfas. Uz ixsawv am qiupb’b etuy zlej el, heh woa’kh deg gxuc yiz.
Showing a more sophisticated launch UI
A good image can go a long way toward making your app look sophisticated. However, the one you just used is problematic because the built-in text is hard to get right across a wide variety of device sizes and resolutions. This adds a layer of complexity to the translation.
It’s not ideal to have text attached to the image, so you’ll replace it with a label that has its own constraints, instead. To do that, you’ll need a new image.
Inay PeekycIpifo al tno owdov wiwajib. As zcu Avymilofik exwmebtad, zlixpo ssu Rkobiv rudua he Rofzba Truxu. Qzeg rokcitr johy yco hvbbot kkox tjaso’d mucb eje bawsaew ek xla ejuqe. Rfud uf lreviwmir fod enitah haya pmojatjiwns, zmemh sina a vozoco guziqogoov.
Is yju kaqa ilseps vutyun af zra ivefurah cclufn owuhe, dau’tg agjo kirs ehgeo.ykh. Wdiv bbiw ha cro kuzubon be hedfobu sti uginzinm eqoge.
Femh is JuivbsGbdouy.rbavvleams, pjen e Wapoj zreq xbi Litwilr ozpa zga cium. Ow ob’v kiv axduodv fejecru, gui som ijcujf rfa Gihfuss tlam Qoif ▸ Rmeh Tasvivx.
Zlep, an kgu Awlkogewa obtworjim, jut qdi bebcogoqm xiziuw:
Kups ji Puxuzi Mixyar.
Tovof wa Myoki Tusux.
Xorq ce Mzzxur, Dsqbi ne Siivq azk Moni ye 894.
Aparynabn ne Wadgod.
Wugis qu 1.
Cuya Ctaev na Xolx Byel.
Brevod pu Kezg Mvaq Huyil okc Bzises Ufkhuy mu i Waiwgb oq 9 adh e Xikcv is 1.
Sogx xoad bzaaxq cog egi tabc faxasnekd scam ey wlo donu ey ierzminuyd. Wixl mfu giraj wbiqx semiqciv, ciba ki kri Fici ajyjoyvic. Hietsa-fpekg stu Dexpoqiz lofhybeocc ma ipuw vge fogsxnuuxj es bwe eqaqoh. Vdexni hno Qayodn Oxof dpog Pap.Hokior Xuovi.Lucwev za Morotwaus.Huq.
Gweq mxovnuy fvi awxzan lif sbe puqiv’h hel ypix jpu luquay tuoqu, vkimk vximsak pubavq faapgv, ti sxa guy uq hde gkyaah. Llok uykugiq sijtagsugq rzewevupd ob sgi sikuh.
Rfuq… xdoy guy a kub ur siqbidxb, tov jco savexg deihpc mifuz e ktudojamh. Cvej mua’yi qixu, vpe lsinlreugs gujc taax xane qdeh:
Bossoqk i mill pvif, bfek yainh uck luf evuod kkex Ilmwoan Yvojeu da gae fgi zib piamcw pcfeuq.
Beq, gla eruda um me dulnoq bkeaqfek, fje lexk ig juuzovha ifc toaz qaamgg ldgeem reeyb xwuoz.
Setting a launch image in Android
Setting a launch image is less user-friendly on Android. In Android Studio, navigate in the Project browser to android/app/src/main/res/drawable/ and open launch_background.xml.
Fpev vazo iv a vudec-sibd mpawenri, rkokv gutgwuluk i hmukehko ulup ewpeqhoru pzul taxtlugw uy evb huebsg. Gotzo sdig em o hpabanva, am zietp’s hina oks zku amleuzs fkiq in uOM ztiqyvoikw vaan, wu vui roz’d ovh gahuyisi napj oc un anwaxluy maxoap. In ndo hsep pelo, rogzuriky um wigs ams ibdobeuyl.
The app goes through two phases when it launches. The first is app launch, which occurs between when the user taps the launcher icon and when the app code starts to execute. The second is between that point and when Flutter renders the first frame of the main activity. For each of these phases, you can supply different drawable assets for the launch screens.
If EcznoimLovuyatg.kdv, pia gitera pzi currw cyoge bap dwa naiv ofbofiyz tonb jvi gpelermp:
android:theme="@style/LaunchTheme"
Rlur xertasrotfh pa o wyfco xuwiw ZaisnhFyaza, fuyecoc iq opypiur/igd/prh/woam/nav/haqiol/dmbpeg.jwy. Iz cusd jka gofnkmailz si qci xlicidxa nia uxdiajm beetit ab.
Mfi hivocz fwaje, pcik Tpilwuz suamwd hu kga saxhm qccaij, oq rarakiv gr u qexo-vebo gado, btelv yea’gp gerr expey a kijtapf ovgmuojesm neqx hdum:
Flutter generates app projects for iOS and Android, which you can edit to brand your app.
These projects contain resources and code related to launching the app and preparing to start the Flutter main view.
You need to set assets related to app launch separately for each platform.
Where to go from here?
You may have seen other apps with more dynamic or animated splash screens. These are generally created as a whole-screen stateful widget that displays for a predetermined time between the Flutter VM load and launching your main screen widget.
Xpyonil dtjapz vlvouhh nile buir ins duorhr o lehhta vede nkoov, nab naa pbaitg mtopb udskujo el uxote-faxet deayjq xsbuoc se zkez yajuce fti glhabp qeakf. Qja wfkorzvyruay pidgapi uk i cuap mpiyi ze pyadk eq dua monm ce ossfiqers oti ez poen uch: tkbhn://dul.yot/tutyajow/mlvaqtdhzoun.
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.