防采集标记:亢少军老师的课程和资料

import 'package:flutter/material.dart';

void main() => runApp(new MyApp(
  //使用generate方法产生500条数据
  items: new List.generate(500, (i) => "Item $i"),
));

class MyApp extends StatelessWidget {

  //列表数据集
  final List items;

  MyApp({Key key, @required this.items}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final title = "长列表示例";

    return MaterialApp(
      title: title,
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text(title),
        ),
        //使用ListView.builder来构造列表项
        body: new ListView.builder(
          //列表长度
          itemCount: items.length,
          //列表项构造器
          itemBuilder: (context,index) {
            return new ListTile(
              leading: new Icon(Icons.phone),
              title: new Text('${items[index]}'),
            );
          },
        ),
      ),
    );
  }
}

@作者: 亢少军

第4章常用组件-长列表组件

相关文章:

  • 2021-05-14
  • 2022-12-23
  • 2021-07-30
  • 2021-06-15
  • 2021-08-01
  • 2022-12-23
  • 2021-04-17
  • 2021-10-28
猜你喜欢
  • 2021-06-11
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
相关资源
相似解决方案