flutter学习笔记: 横向滚动

在这里插入图片描述

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'flutter Demo',
        home: Scaffold(
            appBar: new AppBar(title: new Text('ListView Widget')),
            body: Center(
              child: Container(
                height: 200.0,
                child: MyList(),
              ),
            )));
  }
}

class MyList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView(
      scrollDirection: Axis.horizontal,
      children: <Widget>[
        new Container(width: 180.0, color: Colors.red),
        new Container(width: 180.0, color: Colors.lightGreen),
        new Container(width: 180.0, color: Colors.lightGreenAccent),
        new Container(width: 180.0, color: Colors.red),
      ],
    );
  }
}

发布了96 篇原创文章 · 获赞 15 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_35958891/article/details/103613318