Flutter 组件 ListView
xxxixxxx

ListView

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
ListView(
padding: EdgeInsets.fromLTRB(18, 20, 18, 50),
// 滑动方向
scrollDirection: Axis.horizontal,
children: [
ListTile(
leading: Icon(
Icons.tv,
color: Colors.amberAccent,
),
trailing: Icon(Icons.ac_unit),
title: Text('标题'),
subtitle: Text('二级标题啦啦啦啦啦'),
),
],
)

ListView.builder

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
List<Widget> _getData() {
List<Widget> widgetList = List();
for (var i = 0; i < 30; i++) {
widgetList.add(Text(
'$i 哈哈哈哈哈',
style: TextStyle(fontSize: 30),
));
}

return widgetList;
}


ListView.builder(
itemCount: _getData().length,
itemBuilder: (BuildContext context, int index) {
return _getData()[index];
},
);


  • Post title:Flutter 组件 ListView
  • Post author:xxxixxxx
  • Create time:2020-12-28 14:35:00
  • Post link:https://xxxixxx.github.io/2020/12/28/400-Flutter组件ListView/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments