Create a horizontal list

Create a list that scrolls horizontally rather than vertically. The ListView widget supports horizontal lists.

Use the standard ListView constructor, passing in a horizontal scrollDirection, which overrides the default vertical direction.

ListView(

 // This next line does the trick.

 scrollDirection: Axis.horizontal,

 children: <Widget>[

  Container(

   width: 160,

   color: Colors.red,

  ),

  Container(

   width: 160,

   color: Colors.blue,

  ),

  Container(

   width: 160,

   color: Colors.green,

  ),

  Container(

   width: 160,

   color: Colors.yellow,

  ),

  Container(

   width: 160,

   color: Colors.orange,

  ),

 ],

),

Leave a comment

Your email address will not be published. Required fields are marked *