Flutter ListView 的四种构建方式
1.Default constructor 默认构造形式
- 你可以构建一个个具体的子 View
默认构造
class ListViewPageState extends State<ListViewPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('ListView'),
),
body: ListView(
padding: EdgeInsets.all(8.0),
children: <Widget>[
Container(
height: 50.0,
color: Colors.amber[500],
child: Center(
child: Text('Entry A'),
),
),
Container(
height: 50.0,
color: Colors.amber[300],
child: Center(
child: Text('Entry B'),
)