Welcome to the blog of Sarvesh Bhatnagar

Flutter: All about ListView

When you want to display items in a list in your application, use ListView(). August 11, 2020

When we need widgets stacked up one below another, we use ListView. There are four ways in which you can use a ListView. We will see each of them in use one by one.

First Method : Normally Calling ListView widget

So in FirstMethod we simply use ListView Widget and use the children property to add in the children's.

Second Method : Using ListView.builder()

In Second method we create list of widgets dynamically we need to pass the item count and create a build method which has two parameters

  1. Context
  2. Index
Context is basically the screen on which the item will be returned and index is basically a number using which we will access the list's. So let us take the list myList as mentioned in code, index will basically run through as 0, 1, 2 and 3 because we had set the count to the length of myList. suppose we set the item count to 2 then the index will run through 0 and 1. We use the index number to access the elements in the list but well you can do anything you like with it.

Third Method : Using ListView.separated()

ListView.separated provides us with another parameter which is a separatorBuilder. it also takes in a context and an index. The child is basically a separator which separates the list items.

Screenshots for 1st & 2nd Method :

Hello World application in flutter

Screenshots for 3rd Method

Hello World application in flutter

- Sarvesh Bhatnagar

About Me

I am Sarvesh Bhatnagar, I love to code and I enjoy teaching. This website is an effort to help people learn basics of programming. I am starting with teaching App Development using flutter. If you want to contribute to this website and become an author in this website, mail to: