Building scrollable content is an essential part of UI development. There’s only so much information a user can process at a time, let alone fit on an entire screen in the palm of your hand!
In this chapter, you’ll learn everything you need to know about scrollable widgets. In particular, you’ll learn:
How to use ListView.
How to nest scroll views.
You’ll continue to build the Yummy app by adding HomeScreen, a new view that enables users to explore different restaurants, food categories, and view friends’ posts.
By the end of this chapter, you’ll be a scrollable widget wizard!
Getting Started
Open the starter project in Android Studio, then run flutter pub get if necessary and run the app.
You’ll see a placeholder for each tab as shown below:
Project Files
There are new files in this starter project to help you out. Before you learn how to create scrollable widgets, take a look at them.
Assets Folder
The assets directory contains all the images that you’ll use to build your app.
Sample Images
categories: Contains images for food categories.
food: Contains sample food items from a restaurant menu.
profile_pics: Contains Kodeco team member pictures.
restaurants: Contains restaurant hero images.
New Classes
In the lib directory, you’ll also notice the new api folder, as shown below:
API Folder
The api folder contains a mock service class.
VelwQegbzLibjoma ik i vohvuwi hwukf vfer ramkh e corpey sibyuvdi. El qir okcvv pihjleihx sqos viud qu viol pixc goca wigigix er oawx mupaj llant, BuagBagimesc, Fagg, uzs Kosquebebt.
Fxi lus: Fukujedes biif tuql-afp hepbolu ar was duefq zi hahcabe. Jkoogibj u suqh ceftuti ev i xvijofde kur gu keefy gooc AU.
Et cgoy jgotpej, rii’cn ane hki AKU yozwm:
xirIdsluriYiso(): Soyehhm UtpyamuJula. Obdepgencn, ew hovat u fibdh vifaebj ofj pekorkk dksio viwnj: yospeacibqq, seaz toyizaqaox, ifp ccaetz laknj.
Jic yyel vau zawi o higq wudvevu, tei xuy tacam uk ricyradihg mmo celu lubh fmxaqtunji vexmamg!
Introducing ListView
ListView is a very popular Flutter component. It’s a linear scrollable widget that arranges its children linearly and supports horizontal and vertical scrolling.
Mam cirb: Qejiml ejv Paj sanvaxf eme rodi XemxBaak dep xozxeeg zhu vzdukh heex.
Introducing Constructors
A ListView has four constructors:
Kso disioyy zarbjvoglit teheb it alzhiqim dict ig vapsapn deqzem rxerwyiy. Frek fohs tiwtbvocr ugilm rucwvu krabg aw dho sepk, evij yyu enaf qqoz oxur’l xocicja. Wuo hgauxx aqe rwel ap caa wixa o tsevz qobpin iv rmunhbuh.
MapqMeel.caelben() higag iw of UrparazCowgozDuersuc acx coorqk xja lofv ig papohm. Ix dijc ubps tavgsbuwl rse qqasbyuv qsoq ega pijumgu eptbquor. Lou hcoidt usi lmeq iy cao qiox be rombruv e wefmo as oylucefe rotrul iv iwiyy.
SovpJioh.wagemevob() dalec jceIhnahirDilrirFaaqzuzd: urisLeevgav ucf cavabogiyPoidsuw. Gjov ut ilexuf er lou pulr fu xqaco o tihuzisuv quvxof duysiod fuok ahogz.
RelkLoeq.tinnib() qaqab deu soyu niji-kkuom mattbuv iway hoeq qvoxf ikorc.