flutter ListView 和ListView.build

class MyList extends StatelessWidget {
  Widget build(BuildContext context) {
    //動態加載數量
    return new ListView.builder(
        itemCount: 10,
        itemBuilder: (context, i) {
          print(i);
          return new ListTile(
            leading: new Icon(Icons.map),
          );
        });
    //只能給定內容
//   return new ListView(children: <Widget>[
//     new ListTile(leading: new Icon(Icons.map))
//   ],);
  }
}
相關文章
相關標籤/搜索