OroshiX Personal site and Blog

ListViews and lists

Content

ListViews

ListViews in flutter are scrollable widgets, that can be setup to be either horizontal or vertical.
There are several ways of creating ListViews in flutter.

With a constructor

var listView = ListView(
  children: <Widget>[
    Text("1st element"),
    Text("2nd element"),
    Text("3rd element"),
  ]
);

With a builder

var listView = ListView.builder(itemCount: 10,
      itemBuilder: (context, index) {
        return Text("Element number $index");
      }
    );

Lists

var intList = List.generate(10, (int index) {
  return index;
});