{"id":995,"date":"2022-06-12T16:34:00","date_gmt":"2022-06-12T08:34:00","guid":{"rendered":"http:\/\/blog.xrhoujie.com\/?p=995"},"modified":"2022-06-15T16:20:21","modified_gmt":"2022-06-15T08:20:21","slug":"flutter%e5%9f%ba%e7%a1%80%e6%95%99%e7%a8%8blistview%e5%88%97%e8%a1%a8","status":"publish","type":"post","link":"http:\/\/blog.xrhoujie.com\/?p=995","title":{"rendered":"flutter\u57fa\u7840\u6559\u7a0b(listview\u5217\u8868)"},"content":{"rendered":"\n<p id=\"block-030dfeed-c84e-4fe1-a8a9-e141498a739e\"><br>\u5206\u4eab\u51e0\u4e2a\u5b66\u4e60flutter\u7684\u5b66\u4e60\u7f51\u7ad9\u4e0e\u8d44\u6e90<\/p>\n\n\n\n<p id=\"block-f1339a6b-7e25-45b8-8069-510d5c150a9b\">flutter\u5b9e\u6218\u7b2c\u4e8c\u7248<a href=\"https:\/\/book.flutterchina.club\/chapter6\/gridview.html#_6-6-1-%E9%BB%98%E8%AE%A4%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0\">https:\/\/book.flutterchina.club\/chapter6\/gridview.html#_6-6-1-%E9%BB%98%E8%AE%A4%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0<\/a><\/p>\n\n\n\n<p id=\"block-ce954fb4-619d-4f9d-acfd-5b4395e2016c\">flutter\u4e2d\u6587\u6587\u6863<a href=\"https:\/\/flutter.cn\/docs\/get-started\/flutter-for\/web-devs\">https:\/\/flutter.cn\/docs\/get-started\/flutter-for\/web-devs<\/a><\/p>\n\n\n\n<p><strong>main_ ho_Listview.dart<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/material.dart';\nvoid main () => runApp(MyApp());\n\nclass MyApp extends StatelessWidget{\n  @override\n  Widget build(BuildContext context ){\n      return MaterialApp(\n        title:'ListView widget',\n        home:Scaffold(\n          body:Center(\n          child:Container(\n            height:200.0,\n            child:MyList()\n            ),\n          ),\n        ),\n      );\n  }\n}\n\n\nclass MyList extends StatelessWidget{\n  @override\n  Widget build(BuildContext context){\n    return ListView(\n        scrollDirection: Axis.horizontal,\n        children: &lt;Widget>&#91;\n          new Container(\n            width:180.0,\n            color: Colors.lightBlue,\n          ), new Container(\n            width:180.0,\n            color: Colors.amber,\n          ), new Container(\n            width:180.0,\n            color: Colors.deepOrange,\n          ),new Container(\n            width:180.0,\n            color: Colors.deepPurpleAccent,\n          ),\n        ],\n    );\n  }\n}<\/code><\/pre>\n\n\n\n<p><strong>main_builder_listView.dart<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/material.dart';\nvoid main () => runApp(MyApp(\n  items: new List&lt;String>.generate(1000, (i)=> \"Item $i\")\n));\n\nclass MyApp extends StatelessWidget{\n\n  final List&lt;String> items;\n  MyApp({Key key, @required this.items}):super(key:key);\n  @override\n  Widget build(BuildContext context ){\n      return MaterialApp(\n        title:'ListView widget',\n        home:Scaffold(\n          body:new ListView.builder(\n            itemCount:items.length,\n            itemBuilder:(context,index){\n              return new ListTile(\n                title:new Text('${items&#91;index]}'),\n              );\n            }\n          )\n        ),\n      );\n  }\n}<\/code><\/pre>\n\n\n\n<p><strong>main_pic_listVIew.dart<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/material.dart';\n\nvoid main()=> runApp(new MyApp());\n\nclass MyApp extends StatelessWidget{\n  @override\n  Widget build(BuildContext context){\n    return new MaterialApp(\n      title: 'welcome to Flutter',\n      home: new Scaffold(\n        appBar: new AppBar(\n          title: Text('wecome'),\n        )\n        body: Center(\n          child: new ListView(\n            children:&lt;Widget>&#91;\n            new Image.network(\n                'http:\/\/xxxx.com\/static\/upload\/20181111\/G-wj-ZQuocWlYOHM6MT2Hbh5.jpg'\n              ),\n              new Image.network(\n                'http:\/\/xxxx.com\/static\/upload\/20181109\/1bHNoNGpZjyriCNcvqdKo3s6.jpg'\n              ),\n              new Image.network(\n                'http:\/\/xxxx.com\/static\/myimg\/typescript_banner.jpg'\n              ),new Image.network(\n                'http:\/\/xxxx.com\/static\/myimg\/smile-vue.jpg'\n              )\n\n            ]\n          ),\n        )\n      )\n    )\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5206\u4eab\u51e0\u4e2a\u5b66\u4e60flutter\u7684\u5b66\u4e60\u7f51\u7ad9\u4e0e\u8d44\u6e90 flutter\u5b9e\u6218\u7b2c\u4e8c\u7248https:\/\/book.flutterc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[43,1],"tags":[42],"_links":{"self":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/995"}],"collection":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=995"}],"version-history":[{"count":1,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/995\/revisions"}],"predecessor-version":[{"id":996,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/995\/revisions\/996"}],"wp:attachment":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=995"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}