Create a horizontal list
Domains:
Flutter
You might want to 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.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,
),
],
)