I have a list (say 100) of Widgets I want to display on a screen; the screen can fit about 10 items. In terms of efficiency of painting, should I be using a ListView.builder, or a Table with a SingleChildScrollView? Or something else?
The ListView would look something like this (sorta pseudo-coded):
return new Column(
children: <Widget>[
new Container(
height: 30.0,
child: new Row(
children: <Widget>[
utils.createLabelText('Name'),
utils.createLabelText('Owner'),
utils.createLabelText('Last Modified'),
],
),
),
new Expanded(
child: new ListView.builder(
itemBuilder: (BuildContext context, int index) {
doc_fidl.Document doc = model.documents[index];
return new ListItem(
doc: doc,
);
},
),
),
],
);
while the Table would look like this:
List<TableRow> rows = <TableRow>[
new TableRow(
children: <Widget>[
utils.createLabelText('Name'),
utils.createLabelText('Owner'),
utils.createLabelText('Last Modified'),
],
),
];
for (Document doc in documents) {
rows.add(
new TableRow(
doc: doc.widgetList,
),
);
}
return new SingleChildScrollView(child: new Table(children: rows));
It seems like the ListView.builder would be most efficient since it builds the children on demand. However, the Table seems more appropriate for this task (since it can easily align the 3 columns correctly, regardless of each column's text length, especially between the header row and the content rows).