flutter学习笔记: 横向滚动

flutter学习笔记: 横向滚动_第1张图片

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: [
        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),
      ],
    );
  }
}

你可能感兴趣的:(flutter学习笔记: 横向滚动)