Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between ListView and Column?

Tags:

When creating a very simple scrollable list in Flutter, what are the advantages and disadvantages of saying (where widgets is List<Widget> == true):

Option 1:

var widget = new SingleChildScrollView(    child: new Column(     chidren: widgets )); 

Option 2:

var widget = new ListView(children: widgets); 
like image 233
jxmorris12 Avatar asked Sep 01 '17 20:09

jxmorris12


People also ask

Can we use ListView in column?

You can wrap your ListView widget inside the Expanded widget and this will allow the ListView to take all the available as long as the Column allows.

What is the difference between ListView and SingleChildScrollView?

For example: You need to only show a list of contacts on your screen and the list items are more or less similar (UI wise and category wise). Then you would use a Listview. A SingleChildScrollView can be compared to "ScrollView" in Android.

What is the difference between ListView and ListView builder?

builder takes properties similar to ListView but has two special parameters known as itemCount and itemBuilder .

What is the use of ListView in flutter?

ListView is the most commonly used scrolling widget. It displays its children one after another in the scroll direction. In the cross axis, the children are required to fill the ListView. If non-null, the itemExtent forces the children to have the given extent in the scroll direction.


2 Answers

ListView:

Listview Widget shows the unlimited number of children inside it, but the main advantage of using ListView is it renders only visible items on the screen perhaps more specifically I would say ListView.Builder()

Column

The column is used when we have to draw different widgets in the list. If items increase in the column then SingleChildScrollView is used for scrolling purposes.

For More Reference:

https://medium.com/flutterworld/flutter-problem-listview-vs-column-singlechildscrollview-43fdde0fa355

like image 65
Jitesh Mohite Avatar answered Sep 23 '22 07:09

Jitesh Mohite


Definitely go for option 2. ListView have a few cool optimisations. https://youtu.be/UUfXWzp0-DU?t=33m38s

like image 44
Rémi Rousselet Avatar answered Sep 21 '22 07:09

Rémi Rousselet