Read now

How to create a List in Flutter

In the last blog, we have learned how to create a widget and I think you guys must have understood it pretty well. In case you have missed the previous blog, then I suggest you read that first and then continue with this blog. The link to the Widget blog is here.

What are Widgets in Flutter?

Let’s get started with the List in Flutter

Just as we use Recyclerview in Native Android to display the lists, In the flutter as we know everything is Widget. We can use the ListView widget to display the lists. It is a scrolling widget which displays its children one after another.

There are four options to create a ListView

  1. List<Widget>
  2. ListView.builder
  3. ListView.separated
  4. ListView.custom

Let us discuss the ListView.separated type to create a list view.

As we can see in the above code segment. We have created ListView.separated widget and also assigned a few of its attributes.

separatorBuilder creates a divider line between each item of the list.

scrollDirection will decide the direction of the list.

shrinkWrap will make the ListView only occupies the space it needs.

itemCount gives the count of the item.

itemBuilder draws each item in the list and takes item layout input which is _listLayout in this example.

Let us see whats inside the _listLayout widget

this is just a widget which uses a few other widgets to create a layout which is used as the item layout.

That’s all for this blog. Thank you very much. This is Vedesh Kumar signing off.

. . .


Add Your Comment

Be the first to comment.

Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again