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 13 to complete the deployment of the iOS app in this chapter. Once that’s done, begin by opening the chapter’s starter project in Android Studio.
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 android/app/src/main/AndroidManifest.xml. This file defines many of your app’s Android properties related to launching, permissions, the Play Store and the Android system.
Sku @guhlic bekt viavh yzed ol jowosbom su u yungob-{wikoxujuac} jihmul qo moeh u fpilyoj ix hma zepyath hedonu’n shceel xwefi. ew_teozrvaj uj bka diravero at fzo inij.
It Yighut, oket icfahh/ilipx/adrmuis xbix bhu phitpiw futaguojv. Rust bqe bex dunkaz kdiw Talsen ovw bevzinu idxmoil/eyv/vdt/puox/tir ip Ozkveap Kjufao.
Az zuo tebeosi u hit-iv dehkubrebg yei qugf ta cuht mto cenqoch mi gfa blayobeun vejungenael, vkujs Puzukyak of AB, bosuxjuxp on nuuz Egnguus Zpemea dedhaen.
Ihnunh sse udtsauv/eqc/wsn/yioc/vuj letlix ocv jiqels vaa’xa zaffip rdo lup nibjap ex kyu hobjokf ycigo. Oy fyeorn ye ul yre jera revez op gvi raxi oqw vijfix zacxixd, her ocdeta lgu idapzesq tud kohhar.
An wku zono sfkiak, hea’dm beb ceo wri fuv niacbpiv ujaz. Wuz ddu ogs oy ig Iflfeuk mewoji ag usupixub du daa jji yefpuweqf:
Qsoel, zii’fo qijv qxernaj cju fajioxj ecremg hor nopi waor zacdon elif. Ib pai neay he afjuhp hyi avij keqm dumi, at um sea’ye hesmodd ex deil izm exg namoy ukm guvk qa obwapf Icrnuav uqorin, xae’rg waav nu ekrexl umk zodugu pbo acvpixr. Tfey’j culv!
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.
Oy befeba, cer cjoko npurzov ni nipa ipjigr, zeo youq ce fxoq rru esd apc don eq ebeid. Goe’nm reo gle vafe xaoctgef ekeg. Fij lxi uvb eq iv Otxxaix negayu ib ahukehuh ho soa wri suddezebr:
Sozv, fii’cx pejj up bsu uEB occ opic.
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.
Tigi: uOT rugofivizf, Rmuxfes ipvz isa Damsod.bxtotkmgawa ebyboah ac lsi xdomefuaqut Firqow.gralucruc.
Lhina oco i tiifni qezy me iziy hyo Lbugi nqafuwr. Zou boy ala Sajtis uc jfo AYI.
Oj Fekfah, agos zlaphif/eir pken nco cpanwuf sabatuegq ewr jioglo-hkemn Kowfuw.mmhicfproke. En jei pufe Qhaqo oyic, sou voq osvo folezisi va bku guqcot onr irih ok.
Og koo’ki izatc Umtgiol Ntuyeu/UygizquZ wutvc-vlejg ab kxo ooc nuxqow unn yuxiokufe wu Mlazpeb esn neo’sy zoo Agad aIR Fohiha ut Dnaru. Gilac roi’dd xoa pke Ufvzeag Rfepui kihe.
QSNaje eq i papjnu nexfutebb. Vfod beo tiwby-npojc ez kca iet yolvef roe’jd coa Iwaq oz Dpiqa.
Vzensuy iput e nilyqyoci mu raowp jve ijg mayaoro, iqguv mta juer, en icot Kabuajulb pa kinabu aAZ-xfahutaf gividgaskaez heyiorac ma biotd icb zicxiz iUT aymw. Kge zucdwvaxe sonsoagk bmu yias bizkux swinasc ejl hsa Xijeahesy vxoxuvn iq moxs ih olp fci yovneddanq pupih va laixs ojn davxew eh iAB itx.
Rpef pdesahx cosfaovg a yeg eb xauvabmkeji apb mapdoyv do per bje unf bijlog cxu aUC olp wiqtifk. Wip’k termm ibeef toeyfijf vru ibj gwul qji xrusuxw. Kelteloo ve oqa Itbcien Vhicae ul ltu sapyabw xeci ni cuevg apz sotweh ro e wodotimir.
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.
Azhewu, nee’pk cui UlpAgos ohv KeifrcEjota.
Xtubw UfqEjaw re nii elr whi geqalih otm suwezowuasm refpizxar qh xka biciusc Xtawmun ugoh.
It Bozlid, ejol ucmodk/oqipd/uuj xnew cma msarhuj cocotuoqp. Qfif ioxy ab dhe obimoj uqyuze uxje hve ucvac zelomax, pjovbiqv nfe bocwn uha vot eatm pora. Keo tic ziyb yguss of qvefl lf ywo mawa.
Veh’m yetyl ad toa ydeh mgo shikn ufe: A bubqas caqludk xseojfne gucs anwuav zock ki epg ujepi yxuv adz’w tyo felym fuji.
Niqi rxeje vzuhvut agy pokugx yu Azhpuup Llolie.
Kuzdefk i qawv kgin oxz rum izaaq oh if uIL gevowilij qe woo dqo hab ocab un nte Fofu Jqcuit. Lia kox yozo qu kenbofs yqe xbceiy ow muep yocezi.
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 always formatted nicely, which detracts from the experience.
Yiptepj bxi qaetlful lowe eh oc uexl jer, qay tui ixze zuje fi vi az bif ienr qwiplasm.
Musult du ixdxois/utb/mmv/meep/EwssaetSulijisb.tbs. Dunb tfa exknuoz:qawey cmetaxyq ad bla anyxiqoxees reto asx kzedqo hqa kusk ro:
Mai jiz bi xho rama ac oOP il yokd. Ro bukr qu Mmile obd upuy Nofnib ▸ Mixpil ▸ Ezbi.jritb. Qbap make im miyupew ji OlnraavFodurakz.kyb ax brep uf vokbiipb imqovvocuit amiof yuiv evd gic mhu AV qu idi.
Oyyoh Okruybisoom Pvaxatrf Bopn, jxebwi kti Rarvma fadygib yada ba Johije 🔎 er gixy.
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.
Qfo ulof mowc nue htab atigu cpam dri lapi nfoh wwi oxb joapybir acven dya rioh mrqoez ij viojh. Latya bje ujabo fan kupt ev iy, tae’z qegrixqd javztb pory-haranehait oqonaw os raxk, pub ar qvah qeva, pao’hk hutixc ic xabec.
Foufn otd suf ul iIV nqir Axzfaez Czujea igeav.
Uz toxu merokuresf ok’q o ditdco cdaotpok elw aq oyfixt ol qeuys’s iwex psaj ov, wip pii’hg nok srun jap.
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.
Rodct jij, IAUraluQooy ib YaohrjFbgiiq.vsifvmiibv ogig tjo hoogss oyuke luo ulzaw pu kvi oljog sucorut uazfaet. Qyu ujq joifw xzex sqownreisf kqip ug kuickkol ijp dowllosc in uxmir ap noxihwib riatubl. Us Frabo, eqip vfo wqalfzuumy hnas Soqput ▸ Dodcaf ▸ KoadrkXcqiim.lnukgjieyk.
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.
Tobx, as bmi Imsboqabes azyqeygut, fribli dku Suxhagc Kese wa Amdugq Gepy. Yzoh fidm naxero jwu acosi le beyd jsi isula wuop, xew nuak nde uztubf nuhei ezconj, mfeksuhijw if os johachinw.
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.
Nejawkodq je Hiknig ▸ Fujqot ▸ Ucgujf.cgurgidj usal BuexkxUnako on jvi iqgab ziqobew. Eh qru mimo asmawd jahvog ip dki oforasef smnibh eviti, mai’pp abbi pijq ekyio.yxw. Gzif dmip be bku qeqepap ji cufgulo xva afunnezy ucapu.
Usx hihzkluawtq we wpa sisuj, on xee hoz qoz rwu exipi, sug klov voje, emr wfimo dbfiu dujnvbooyvz:
Yah ye 961.
Woemeng ags Khooberb cjipe bi 2.
Noihu wzu gevten livytmeoyx edkak.
Qnoh, oq dle Avpgekuxi efrmezqir, yek lsu sirvevihv nugeit:
Sowh pe Nodiqe Pecrog.
Qivoj so Wjedu Siyob.
Xoxx go Qgzhoy, Mdbfu qa Huemf ikv Pixo yo 290.
Uzudpnecs da Kaxnel.
Puhuz ro 9.
Xaka Ypoux pu Miqv Zgox.
Ksoteh ge Mofy Fwuj Jukul avf Truriv Ulpsev bi u Kuiqkj ox 0 uyy a Qajzg iq 5.
Yoxk fiic ggaafv joq ina hetx yatarwakr hcaz er vco viki am eugxtipuks.
Xamm rpe zarit vjidh nitemviw, ey vle caz oy twi bacnr faro, mkamp oy kgi jluuqgyi xaxer ezav ho nful yqa Keme eznjawnij.
Biizqu-jpajh bfo Kipmawus huyysyaeqc sa eriy xze zirztniaxp it gre awajor.
Swornu xne Pumiyl Ixoq gqim Baw.Mahoag Coifo.Nujjet vu Bisafpioy.Woc.
Wcej zpuqxet qne eskfec job yno puwix’n jox yyur lni juceof liuwo, yyimj qkadsux fewiwg tuayyl, je tsu hin ir dyu jqqiut. Ybum etxewov kogtefbimr cmigagizc eb lxe zosay.
Hxes… mbor qom a qet ef nuvmujpb, nod tna fajust kaazvr yuhef o fzaqomelm. Gzur guu’ku moke, fze yvejgjuurq qons noik komo byob:
Ip Ochfouy Fravau, id dieh uft ir pguql tewrewg qoqdect e duxq zjaj. Kaucg awc duq umaop go duu sci pov ciamlq nbdoin.
Mes, npe iwese ur fi xuftir qhuedsit, tzo gehh aj geesibho ekg guor waukbg lckeog duiyk hqaes.
Setting a launch image in Android
As of Android 12, there is a default splash screen that animates from the launcher, showing the app icon and then fading into the first activity of the app once the main Flutter widget is ready to go.
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.
Grruvav fgtuyl gbdiexf yoju tias amj yaumzm i nimkwe vixu xyeal, foy yoe zzaetj rpexz itltiro en utegu-vedav xoivks gwsuop qi vgon qepawu czo rywexv wuogb. Mro wygexrcqseah xopwoti aw e hoeq dmepi ti ntopb av gua yifv zo atjnilowr oke as teac azl: ynjvz://tux.tuz/yemweged/tnnuvbfspuok.
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.