Flutter笔记4-list动态表格
2019-01-17 本文已影响30人
叶小七的真命天子
import 'package:flutter/material.dart';
void main()=>runApp(MyApp(
list :new List<String>.generate(46, (i)=>'我是列表 $i')
));
class MyApp extends StatelessWidget{
final List<String> list;
MyApp({Key key,@required this.list}):super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: '动态表格',
home: new Scaffold(
appBar: new AppBar(
title: Text('动态表格组件'),
),
body: new ListView.builder(
itemCount: list.length,
itemBuilder: (context,index){
return new ListTile(
title: Text(list[index]),
);
},
),
),
);
}
}