直接看如下代码示例:

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() => runApp(DemoApp());

class DemoApp extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'ListView Demo',
      home: new ListViewDemo(),
    );
  }
}

class ListViewDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: Text('ListView Dmoe'),
        leading: new Icon(Icons.menu,size: 40,color: Colors.white,),
        actions: <Widget>[
          new IconButton(icon: Icon(Icons.search), onPressed: (){
            Fluttertoast.showToast(msg: '点击搜索按钮',toastLength: Toast.LENGTH_LONG,textColor: Colors.white,gravity: ToastGravity.BOTTOM);
          })
        ],
      ),
      body: Container(
        height: 100,
        child: new ListView(
          scrollDirection: Axis.horizontal,
//        padding: new EdgeInsets.symmetric(vertical: 10,horizontal: 10),//子元素设置水平与垂直方向的padding
          padding: new EdgeInsets.only(left: 10,top: 0,right: 10,bottom: 0),//子元素设置左、上、右、下的padding
          children: <Widget>[
            //数据源
            Container(
              width: 50,
              color: Colors.blue,//颜色资源
            ),
            Container(
              width: 50,
              color: Colors.green,
            ),
            Container(
              width: 50,
              color: Colors.amberAccent,
            ),
            Container(
              width: 50,
              color: Colors.blueGrey,
            ),
          ],
        ),
      ),
    );
  }
}

 

代码相对来说不是太复杂。