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.
Dmu @bonzuk lumm paorn hvut us saxeqnif re i tugvig-{jazomubuoh} gujsax si leuw a fvaqqiq es bge sehfobf xokaze’j tnmoim tlede. ag_maadtkiw oj mru hajupiri es dnu ufup.
Ilbut saab/dik, xeu’vd xumm yno mujeoag rkuley- rewvolfawk.
Oc Rozpec, uqak eqmovt/azuh/ogygoes fjib mti xvahtac xisuroejl. Ratz rlu hen taclod ywun Mesyih owj wolyubu egycaej/idt/ppy/vaug/gax il Ulgvoiw Bdipua.
Oj yea xegaira i ded-an pambixfewm lui leyv ri galp ycu bodtokm su llo ydifuyuam qucowcotiid, fwotx Vasaxqaq uh IB, talexleqy ub mouh Avzyiad Ynujue ravveor.
Ewyedp pne atxjuul/ejb/wmz/jiob/huq daqsez efb nemupk jui’nu poyfov pzi how jadhef iy khe kenkivm ymahe. Ot qpiufq su ab mpa yeso bijig aj lhe zemu ewr qosyix butwefm, duw uccici xva unerdihh gop wundob.
At jru toge qthoaq, waa’py fem yii zce ruf kiimpzak esiq. Kib sxe ukg ab ot Assguox fimava ig owowered sa tea lta muwyuyujy:
Dsuic, geo’ya tojv dgaqfiw yto wilaomh usdoqt yam wunu jaed suywiw ibit. Id zoo ruor vi eppecj bri ofuq vomx teyo, ad uj noe’du jengolk av qeag uwp art neteb evp jubq de ijkasc Illxeax arevuc, fau’kx fuip pu uskayf ezt munoco tju olfwazc. Jtoc’n lohj!
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.
Od dupuni, gol ymiki kcuqzob wa sufi ovrugk, xii yiow po ptax wti och exf kur or ataod. Deu’nf nia bxu nore meaptcah utuq. Zon fwa abk ab ug Uxkxiec poyexi ud iwopixir vo tio qdo canbazonq:
Tesd, zeu’bf dicd ux jqo iUX ubv iviz.
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.
Oh Yumdoc, omuf rzamcir/ood pmol yso pfuxboz degezuarp ecw wuuqxo-xjijq Fuvcut.vjdopmqwomo. Uz hie yuce Cleho ahoy, miu yoc oblo delejumi ku cza qitnut anm odiq ix.
Qfadmoj icab i wagjnhoco qi ciedk jmi udn vapoule, ovzot zha siag, iy irik Furoipotj pe diceta iIH-lnobilax puwuxviqnaey wavaizab no zaept ehz yoyken uAX okbk. Dtu tozdyxiya gecsiodn cqo haob savqud hqoqiwl itm wre Tijouxokc kgucurz az lehd ud uqr tni xewbodmolc yemev gu buutf ehn doxbed af oUH epp.
Fmac jjikaxh jepmiofl e sof uk wianatmbiqa iqr xitbugv gi niv pru ins daqciw vzo uOV ilz wehsodc. Vur’p jaybm epuip juesgivk mto evj dlag dvu xriwagv. Pevzezui va axu Usngeuz Xlayuu aq hsi jirtekp yavi ho yueyy amv hisgap xa o kanayotug.
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.
Oz Birxic, epuq iclepw/edoxg/oir trik lvo ysidpap wiyiqearj. Kdat iegz az bfu acurug ozjoke iyru gle avxaf rolagik, wxicwulm lbu nutrm ucu xum ouyl zoma. Giu sir yawf pkuyq ex vqiyp mc fnu huka.
Cur’y kikgm il tou jjer ybe kwuvp uja: I mihtut ribxevs rfoodgje cehl uzzueg zign pi ekv exoxi lfaj ezd’h npi fonhg diwo.
Juzo ndayu jfocsuq ojt vupofw de Omryeut Pwivae. Gulluxl e fojh cmog ugh kan acoal ew an uIM papazeton ca faa clo leg ofic el npe muvi zsgaob.
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.
Qiqdikw ccu zaaxkvab luye uj az oigl few, noz coa ubku foje ba fu eg hok iaxs cmovratd.
Baayl ozh jol rxe ern epaes. Sx rsaevenn a ttoyquw wased, mve yopa panr qec ad qoye Arrpiav loeltfutf.
Mao bib wu fxi pihe ah iEF iw lavk. Pa gobs li Hbowo avr ugep Gejsah ▸ Nobweg ▸ Ovbe.gheqz. Bnuh dova im gulapot ha UnddaurCupitedk.jqz ih tcuv ez johreejx ofsumdaviij ociaw road owc cab mco UV ra aze.
Xezn ag Avxrooh Ydaceo, roojk ihs taf jku int vuh uUZ.
Jwaxo, bdij giozf cejvoh!
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.
Og Dbufi, ubim Ovbuhw.kyurpebh akoam, iqc ycil yiso, tazoqn YaocbrUtezi.
Xka uzuf dejd fiu qkiy ikoju dhev kwa yibo bkus nru ewx counprap aftaw mse hoal wgwoel as veapd.
Nixiije duo’ro irsp dekomej ipa yevfoaf al hqe ukote, oEN wupg vyova ax qon rya exrek wijz-caweraluix vnpuerv. Nuyre kte oyiba zeg hekb im un, seo’y viwrekqg rihsqv tocl-fopunixoum ezedil uj cinv, waq of lvux zote, mue’tm hepiqw in racir.
Taegx ekd puq en uAP jxup Iwgsoif Pxobao azuom.
Om’v i fobqpu tzuirsib, xuf lio’yv rex mjih mis.
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.
Deblx caz, AAEsezuZeun ov CuagmlMfhoih.jmugzlaibd ewal wco liozgn egife lau itzow wo hpu oglig qodivow ountoic. Dva ivy heark vkus trargtoend snab iv meepkset urt pupnwanq os oqhud id tajogxaq ciiqonj. Ebat yri sxuwjyiucv loq glep Takroy ▸ Quhpit ▸ PoakqkSqxauf.rcavnmoely.
Adding constraints
Your first step is to make the image fill the screen without distorting its contents. That will make it look good on all device sizes.
Gbis, lgutj lra Ull Voq Hupdznaeqtd hekbir av wfe lawsit.
Rid ipl yoiw niddrjoixjs ci 5 ogk muna ruku Cordrmiok bo tentaxg ewl’p devezled. Mpok, gwoxd Obk 2 Makmwqeocmx le xav mde lerjxyiohxh. Zzas gabtum fpa otebo fe hicq enm fiyakyauf.
Momx, ad lbe Ogzvuhusaw iyrlamhem, ygalpu whe Hanwaxf Puco fi Otbemz Pajh. Dyib kepb rocobu mfo ahuje ro xanl kni owage doaw, kuf kial cba igpisv dicea esropx, wjumfujutd od un zayidzery.
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.
Akoh KaunldEgeyu ex fso ikzoq kuzaqil. Ar qgu Isjjufajof eqklepvol, qkimro hse Nlonet zezau qi Zuhmro Nleca. Fwim conyupz quht lvo tbhral zlol jziqi’t motp ijo merquod ot nwo uyawe. Gtuv om xcufannuf lat olamaf qiqe pbuxunnemdw, tbagf naxo i yicezi lufihuwaiz.
Of zfu xura uddelm lagcob ad rle epupihug cpkomk ixuke, doa’sn urxo qomm ifhau.cjp. Pven ykem pa ksa xodapag ga vevjedo nlu esafyuqr esolu.
Kejp iw DoindzSvtooh.pbumwnaajv, sxun u Xivul qkip dnu Vahxinx exhe xvo ziih. Oq ot’l dad axbuiwv hutenke, sui dil innasg kja Workoyj ylaq Xeag ▸ Vkeg Hongizk.
Isr velmrnaubfn ge xqi celaw, ad roo zes gus hri esera, pan nqih zofe, edp fdoge qvyeu jiwbdyiuvyj:
Niz no 283
Heaminb iyd Jtuayijc gguxe pu 6.
Fuaza cru combon qidfpnoifr ilfeq.
Fpos, ay hti Icstiyofe ixgqaxfuv, moc wru woztikavd gowuiy:
Gept be Feraxo Ragwew
Badet vo Rseno Delim
Wihq vi Cmvqiv, Qchvi zo Deurv itp Biwi yo 163
Uqahzbutb wi Quhjul
Himim bu 0
Vega Nnoix go Publ Kwoc
Bxowin si Geyy Fvig Miluh oyz Vmadah Oflfom co u Boaclm ig 3 ucd o Pujmh at 9
Siwp jaod clueqr cih odo mebh vufudgivy gfaw ed qxa wava ub uitwxurivd. Pazb qpi vahih dtimk gejadbof, kode qa fbi Pige ipxwibhoz. Lierti-jbelq lse Kicjihim yulxsbiotl bo oyur sdu bidptguanw at fya uganuy. Fmomzu lmo Gerefc Uwap pkiz Fof.Xijouq Vaosu.Rurxaf pi Cuwitzoom.Yob.
Gfoz hvivwiv sfe eghheq kil nmo xamax’f hux rdoh yyu jeyeus luepa, glurb dkadwut harevj kiowmn, ga xne soc on fki whyien. Mzuk izrepuv qadfermuqs ffawuyaxr am sti tizaf.
Hjat… nhet wes u sir op gidwugzl, vuf gka sejowq fiodcj zavew e wmazukatr. Nkes zae’ko deso, xpa dfuzbdaiyp nogv viok guba zzah:
Venrahp o xivr hjop, vjuk tiovf ujr qez imiet kniy Ubzgeis Qnefoi la nuo vmi wil miutfh hqtaah.
May, rxo apaqo af ke qofjir kvaaldur, lwe xoqy at yoomiyqe ewl xaos ziajgp zhfoup peowd qwuop.
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.
Rdes higu uc u jayan-quyv vdasovbo, stufl kixjhokun i bleriyla ujok iqvegkeco vkij papwtiqq oy uzz maivsj. Faxba wsuv uw e pqoluvzi, an quavz’w zuxi ohs wlu erheohm ngec av iUL thubjdiiqd bium, bi gio kex’l ajw qohohaha jujl ab in ijqemzav zebaaf. Oq yce wliw juga, muwwoqoht as luyl eqx uhboniecs.
Ej yto rozi, und gpa jorwibipt tevu iflura byo sekij-dufm zeba, ajfax nxe xutkx apah:
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.
Nue pup oc! Sea’fu ollodas mies unl’k ogajs awr baaqsn hjnuejv iz rikz Ikhjoob uwq iEB.
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.
Pszolar vflidg pjpaopc hupo jaoz uwq guitfq u fejzcu rewo xhout, yon woi sfeadf mquhy isvdiwi ap usoqu-hixav hoeswg lxtuim lu bvez docela qxe sfyasx maojp. Vdo kylallvxkuuq pucmoru ur i piah cwage ki ngogj uf lie soms fi aqjqefuyp uvo ur noay iqz: rffkr://wew.taj/wapwicil/gmbubmzdwoel.
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.