listview scroll flutter code example

Example 1: make listview not scrollable flutter

ListView(
   physics: NeverScrollableScrollPhysics(), // <-- this will disable scroll
   shrinkWrap: true,
   children: [],
 ),

Example 2: flutter listview scroll horizontal

ListView(
  // This next line does the trick.
  scrollDirection: Axis.horizontal,
  children: <Widget>[
    Container(
      width: 160.0,
      color: Colors.red,
    ),
    Container(
      width: 160.0,
      color: Colors.blue,
    ),
    Container(
      width: 160.0,
      color: Colors.green,
    ),
    Container(
      width: 160.0,
      color: Colors.yellow,
    ),
    Container(
      width: 160.0,
      color: Colors.orange,
    ),
  ],
)

Tags:

Misc Example