美文网首页
Flutter笔记4-list动态表格

Flutter笔记4-list动态表格

作者: 叶小七的真命天子 | 来源:发表于2019-01-17 15:24 被阅读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]),
              );
            },
          ),
        ),
      );
    }
}

相关文章

网友评论

      本文标题:Flutter笔记4-list动态表格

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