Flutter Widget之ListView

Widget:https://flutter.io/docs/development/ui/widgets
ListTile:https://docs.flutter.io/flutter/material/ListTile-class.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import 'package:flutter/material.dart';

class ListViewDemoPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => new _ListViewDemoPageState();
}

class _ListViewDemoPageState extends State<ListViewDemoPage> {
@override
Widget build(BuildContext context) {
List<Widget> list = <Widget>[];
for (int i = 0; i < 20; i++) {
list.add(new ListTile(
title: new Text('title$i', style: _itemTextStyle,),
subtitle: new Text('http://www.appblog.cn'),
leading: i % 3 == 0
? new Icon(Icons.settings, color: Colors.blue,)
: new Icon(Icons.favorite, color: Colors.blue,),
));
}
return new Scaffold(
appBar: new AppBar(title: new Text('ListView Page Demo'),),
body: new Center(child: new ListView(children: list,),),
);
}
}

TextStyle _itemTextStyle = new TextStyle(
fontWeight: FontWeight.w500, fontSize: 14.0);

Flutter Widget ListView

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :