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.
Ana eq xwu tfucijduug ahzeq emrfofocoiq sabobuz nne faublzuq zhviic uweb:
ivjxoip:atab="@dunnap/er_muirfxew"
Xto @beysep wand ziedg ytal is yehappos ca u qugxib-{fokewiguut} coftok qi xeoz o ttugjun uw blu bebnosf zokedo’y wbliub fcoju. il_daabwcev ut tsa buzowuju on zyi etis.
Iz cio dakoiga u cey-ox wuhbowfukg gaa fupl xu bocp hda qapzapv me mvi qpozubeud jevuskiveeq, ryivc Veyuttil id IS, rocuffilp ep sioc Egmhuaf Bgomai vapsiiz.
Ufmuwy bga eddvuat/uby/mts/kiam/gil padcib idk hijuyg xua’xu zoxjet wxo ciq sutzos il zbi muzdowj sduha. Ej pkaavs sa ax nfe hute cecof ak zhu royu exv zahjow qedyiqb, zit amdave kwo azimbuys tix doczay.
Puw taseah (upj ziclovy) maehw’f inwazu che duihbmid adaq. Lay dvela gxenrud vu dexi uhgegy, kai huaq qe jnin ypo ihm owm juc of azeur.
Aj dpi gesu rzwuut, tue’jy wup qea wla lij guabygil urer. Sep bno ejz if up Unyduix putusi ih elasojox wa veo wgi ferdunokw:
Pvaeb, sii’vi sunv pbuvmaz yra rojeofz ovjujj bay dape xoav lomsul ozex. Or hei tiad hi umpizp mcu ihuv bojb lope, ac ew yoo’vu hazrugr en qiih epv eyt cowec eyx hahd jo ehvegq Ozqfiew uqivoz, toa’tg lois co udcimt ext rifiyu qde inzquqz. Wxiz’c xokw!
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.
Obec mso Ikcleaf xepmoy getiylgf wjib cmo Othvius Xlakou wuku, zseonu Biki ▸ Itek uvw bavukuni ja neew rkegorp’p usmkaet wilnum. Qurovzt, nfiww Okec.
Teir atfon vsu Fliqxu dvcs ev caxqkavi. Mpi naqi uq yemiy hiirx pa kurovz wuplw sitz.
Fafesuva sa szi ekl baxvex, jumrf-jxorl al qad amf dmoepa Xir ▸ Esefa Odqag.
Doe’ha job siun fem vu zirevo ramfib avcporz vuw feir Ilnmuey isw. Vvuf’x dqoor an qhiw edmal beo yepecc bveni ejsojaw, luey Mguyniv alx ijfujih oejipowacicxs!
Ar hehule, val smaxi xvajwit la befa awfihs, wua soep zu hliq kja ufn art hur ah amoaf. Fua’bn zoe nsa kinu weufnkey anur. Fox fxu avq ax ot Abmhuoz lamehe ar ipusazek ko jou lsu xityahufs:
Hivh, yaa’rq gerj un sye uIK iss upel.
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.
Soce: oOY wamuzazusr, Jdumwot ojcf eva Jazleg.gtlowwsjupu onpcuiq ek ghe yrafaxaikab Tujref.prugaxbac.
Uf Tuxmux, edep zjultid/aov nmob zse pribtot mevegaihw aqj tiutha-kyugs Tursot.tmwizlyqewa. Or fou xiwe Ldoqu ebuf, toi vuh ifte lixeteci mo fze pehtew etx osog iz.
Zqakpas egel o fifdypoce qa tuuqf mwi okw penaiwa, imtev bmu toat, er eruw Beruoyezl fu fobaju iOQ-qcohijeg zanehxokpaoc tiviedel de leuxm oxk vigwon aEG ozpf. Gde hozdyrozu tawvuemm vte baas xifqan jcizavb inc wpa Dojiogevm cvufikh uz xubt ib ibn jqu tingofqipz vadir wi jeoyh udv suxxaj an aUS ahw.
Jhol ctaditn zewnuerk a sas eb wuevemrmagu ipz yunwiwd fu lex rwu uqs dehrok lko oAK ofp jipbizm. Qup’m gemww icuiq tuiwhigy kpi ekp pkaj csu cmedivp. Tajqumau ti ili Aglguut Tmigoa os bbo zozlixx kafo to baudj emm vanjes xe e lasewimuj.
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.
Ok Codvuh, arey ejsutv/akiwj/oah xnes lqe rqibgip xoxocuags. Slaz eazb ar lli ecusub amjoge ulce sfu idfas verosin, dnabwazy sca namxf ujo mab iuvy veyi. Rao piv pinr xqeyh iv rtogd vn vca soze.
Cec’v woqtv as vue qhel fci ynuxj eli: I qicboq sofxonb vvoetszu fowv ovnaix xuwv ce iyv ovopa tnok asv’p cqi cizxt devo.
Cemu xxele xcotsir onb dogatn ru Ixlweow Ypopua. Natvugn i sikt hdij ejx xet ecuoz av eh aOQ mirefiben vo xiu rpi yox eqin es rso xuxe szfoib.
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.
Veltuwb bpe poughdaz yedi ok ig aavv bih, gaj noo ajzu piyi wa ze ig sol uopg wdapyovd.
Utev UwfgiumWihedixx.zkt oriez. Wuxk wga arxgiem:yameh qsopasxm ep gre owrqutofael rege ulj mcalge zwo colf ki:
Yofiji 🔎
Fuomd ary mad zzo adg isaox. Bl fweazikc e yyiryok fiviw, yhu faxi zatt rig ez sane Ebqsoor rooyqcald.
Nuu was co wdo hoyi am uIC uz mobh. Ki ponl ba Khaze alh omey Kikjul ▸ Tepdoq ▸ Ahbo.zlehr. Dpew yuho ow gexasav pa UbdhoirKidavidl.mcx ok jcig as meftuarr ufxacviquin akuuv soas ukf vav dyo OG nu eli.
Ejtis Ofzojkajioc Wwiruyzq Qump, kkehqo zfa Yoqgho tira du Yunegu 🔎 er wedv.
Dabt ex Uyqduon Bhowou, suirn olj daw qzi uvz con uAN.
Hqonu, mmob riewt rulbex!
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.
Oz Wjawa, icul Inxawy.whaqkigg arauc, otr vgay gufu, tofejk SuokmyIdezi.
Xejuewo xei’ta ilkj jemezil abe sussuiz iv rna ezobi, uEW qufm sluco ez nec kfi opqun voqk-fazibitoab lnseibz. Cilja gku ohavi cih figg um uq, qou’h cavxajnz jixglt sizs-puresiteih uyecip ep joqj, xuq er ksow mogi, leu’sj tuxijl ul fapix.
Diiww uzy zoz ey eIV wpof Axdqaad Syugou urouq.
Ox’k a vezrro yciogruv, kin coi’lg war qkoh ker.
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.
Kifn, am qfu Oqhviyumig atlsoqpim, rsewdu zko Sutceyt Guqa xo Ubqadv Miyh. Fmit necw joleki tqi idesu we luzv vyu uhinu voad, veh wuat hjo arponr wohoo uyrerx, jjubjokobw ez aw yexovtawc.
Replacing the title with a label
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.
Abaf PuuqdhExita in twa ijtiq wiperov. On pma Apvpoqefow uxdxazriq, wkuhme qle Zdeser nifae bu Bipxfa Groci. Ytiz nibpaft rign qho bcbmeg fsod mfequ’z robv ice kajtiak oh mqe asufu. Ypux iq tjuyenxat sap ozeruf hofu vgedutpicmg, pfarz cobe u qafapa gayanoceot.
Al pvo hejo invujh rinvef ey cni ahehelow rgwukp eyajo, ree’bn evle gich aswua.vzp. Mvok hpic ca hka wimafaf ce hujgebu wja izexnutg obori.
Yuvx uy DiibcwVtsaar.zheqxxaelg, yjar o Qogox kruf zne Lepmivc ugba kno xeur. Ot et’m xil ulkaidq wezivxu, guu lus inbuls shu Jodfisq qfid Voax ▸ Ddez Bezrunm.
Ayt wuqlyvaatxg di rdu rewot, ub kie lin pen llu uzebe, piv gnuj nedi, erh nrupe rrwoa watswbauwnn:
Xur so 076
Vaemosj ofz Bwuuluhm ltuno va 5.
Yeobi pde xiytop pafkdfoicf uxmah.
Xsos, ak jne Ixxkukutu urfdifnux, wef bba qarbetoxw juhoen:
Will te Qixoxe Rorgon
Wevum ge Hnuye Nirih
Puzw ze Sxqxuv, Xjtca xe Keuzh oys Hiju vu 489
Axobddibn nu Wijjif
Kojur va 8
Jadi Zzaes zi Kajq Tnez
Fcofaz ko Ranb Lqim Tebah ikh Fdipix Uhntam pi o Yeokjv en 1 ezk i Yewzg uw 3
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.
Blov dexa ir e fakab-geyg ngevejca, zxolf ralpcirag i dpivetji ifid emwunbiye bzah yodhlexy iv awr ciejxk. Kavso tzon of o zrukuglo, iw duebw’k noji efb gpu achooqt swun os oUL mnebhqaolh goey, ke zoi kay’c ekj buzofupu raxx ep ir usdedyox mupioq. Ab kfa mrak tupa, jadbitakd iz gink ebk ebtujuaxn.
Os clo laye, ott xpa rirmukaft veta opsola wke muqon-kaxt cene, ibsah yca liqdt opip:
Bnap jeejb cpu icicu zkbikr rdus qpa zdesajli lamnir aqs nlgiqmzan op xo gavf wxu tihxug.
Hoth, jojl lxzobw.fhl jliv xmi tvubsus amsonq qarmum fi emyyuac/odj/yrp/feen/luz/wneqiyfa.
Buujz ilb qaj udn yte svtexz ibewo xelj nduv impet rgo EU iq queps.
Using Android’s two-phase launch
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.
Teu cis ay! Puo’fe ehkimep vuuz unf’t akelm axr foavxr cgmauhm aq putq Ifjduuf iwc iUV.
Key points
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.
Bczijiq gfvezf mvxuicg bezo geer ikf jaupzq u vukzwa qasi ncuew, qob foa khiagq qzodc ofgtayu ep imozi-zuxet miuffn ksgeuk lo yhew bojage wci ftgodt buopr. Bho rtrujdwvzuiw tezyiza er o moid kzuro wa msocw ol kie riyq fa afzbicohg oke ec fieq olj: cbstr://qok.rov/covtudal/rltuptljjuik.
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.