美文网首页
flutter控件之ListView

flutter控件之ListView

作者: Mr丶xi先森 | 来源:发表于2018-09-11 16:17 被阅读566次
    import 'package:flutter/material.dart';
    class LearnListView extends StatefulWidget{
      @override
      State<StatefulWidget> createState() {
        return new _LearnListView();
      }
    }
    class _LearnListView extends State<StatefulWidget>{
    
      final List<int> data=[];
    
      @override
      void initState() {
        // TODO: implement initState
        super.initState();
        for(int i=0;i<100;i++){
          data.add(i);
        }
      }
    
      @override
      Widget build(BuildContext context) {
        return new Scaffold(
          body: new ListView.builder(
            itemBuilder: (BuildContext context, int index) {
              int itemDat=data[index];
              return new Row(
                children: <Widget>[
                  new Container(
                    child:new Image.network(
                      'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=15335368'
                          '41326&di=682e2e7c3810ac92be325e62e173c0ea&imgtype=0&src=http%3A%2F%2Fs6.si'
                          'naimg.cn%2Fmw690%2F006LDoUHzy7auXEaYER25%26690',
                      width: 100.0,
                      height: 70.0,
                      fit: BoxFit.cover,
                    ),
                    margin: EdgeInsets.all(10.0),
                  ),
                  new Expanded(
                    child:new Column(
                      children: <Widget>[
                        new Container(
                          height: 70.0,
                          child: new Text('这是一张非常漂亮的美女图$itemDat,喜欢就赶紧来欣赏吧,等着你哦'),
                        ),
                      ],
                    ),
                    flex: 1,
                  ),
                ],
              );
            },
            itemCount:data.length ,
          ),
        );
      }
    }
    
    1.gif

    相关文章

      网友评论

          本文标题:flutter控件之ListView

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