美文网首页
第四节:Flutter ListView 列表组件简介

第四节:Flutter ListView 列表组件简介

作者: HT_Jonson | 来源:发表于2019-06-27 17:20 被阅读0次
image.png

一个简单的listview 列表 这个是APP开发中常用的功能

直接贴代码,没什么技术含量的,就是先测试控件

import 'package:flutter/material.dart';



class CategoryPage extends StatelessWidget {
  const CategoryPage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title:'ListView',
      home: Scaffold(
        appBar: new AppBar(
          title: new Text('ListView'),
        ),
        body: new ListView(
          children: <Widget>[
            new ListTile(
              leading: new Icon(
                Icons.access_alarm
              ),
              title: new Text('access_alarm'),
            ),
            new ListTile(
              leading: new Icon(
                Icons.access_time
              ),
              title: new Text('access_time'),
            ),
            new ListTile(
              leading: new Icon(
                Icons.account_box
              ),
              title: new Text('account_box'),
            ),
            new ListTile(
              leading: new Icon(
                Icons.account_box
              ),
              title: new Text('account_box'),
            ),
            new ListTile(
              leading: new Icon(
                Icons.account_box
              ),
              title: new Text('account_box'),
            ),
            new ListTile(
              leading: new Icon(
                Icons.account_box
              ),
              title: new Text('account_box'),
            )
          ],
        ),
      ),
    );
  }
}

横向listview

new ListView(
                scrollDirection: Axis.horizontal,
                children: <Widget>[
                  new Container(
                    width: 180.0,
                    color: Colors.lightBlue,
                  ),
                  new Container(
                    width: 180.0,
                    color: Colors.amber,
                  ),
                  new Container(
                    width: 180.0,
                    color: Colors.deepOrange,
                  ),
                  new Container(
                    width: 180.0,
                    color: Colors.deepPurpleAccent,
                  ),
                ],
              ),

相关文章

网友评论

      本文标题:第四节:Flutter ListView 列表组件简介

      本文链接:https://www.haomeiwen.com/subject/sbnrcctx.html