Posts

Showing posts with the label Create a horizontal list

Create a horizontal list

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. import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget {   @override   Widget build(BuildContext context) {     final title = 'Horizontal List';     return MaterialApp(       title: title,       home: Scaffold(         appBar: AppBar(           title: Text(title),         ),         body: Container(           margin: EdgeInsets.symmetric(vertical: 20.0),           height: 200.0,           child: ListView(             scrollDirection: Axis.horizontal,             children: <Widget>[               Container(                 width: 160.0,                 color: Colors.red,               ),               Container(