简体   繁体   English

颤动:如何删除Listview中行之间的空格

[英]Flutter : How to remove space between row in Listview

I am just doing some demos of flutter, I love to do it, In listview, I cant find out that how to remove space between rows 我正在做一些扑动的演示,我喜欢这样做,在listview中,我无法找到如何删除行之间的空间

在此输入图像描述

my code is pretty simple, This one is Widget which I return to my layout 我的代码很简单,这个是Widget,我回到我的布局

Widget _getWidget(BuildContext context) {
return new Material(
    child: new Container(
      padding: EdgeInsets.only(top: 20.0),
      color: Colors.blueGrey[500],
      child: new Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          _getHeader(context),
          new Expanded(child: getListView())
        ],
      ),
    ),
);

} }

This one is Listview 这是Listview

 ListView getListView() =>
      new ListView.builder(
          itemCount: widgets.length,
          itemBuilder: (BuildContext context, int position) {
            return getRow(position);
          });

This one is row which i use card view 这个是我使用卡片视图的行

 Widget getRow(int i) {
    return new Padding(padding: new EdgeInsets.all(10.0),
        child: new Card(
          child: new Column(
            children: <Widget>[
              new ListTile(
                title: new Text(
                    "Name : ${widgets[i].username}"
                ),
                subtitle: new Text(
                    "Decription : You may go now!!"
                ),
              ),
              new ButtonTheme.bar(
                child: new ButtonBar(
                  children: <Widget>[
                    new FlatButton(
                      child: const Text('Accept'),
                      onPressed: () { /* ... */ },
                    ),
                    new FlatButton(
                      child: const Text('Reject'),
                      onPressed: () { /* ... */ },
                    ),
                  ],
                ),
              ),
            ],
          ),
        )
    );
  }

Help Me. 帮我。

The spaces that you are getting between cards is from getRow() method. 您在卡片之间获得的空间来自getRow()方法。

Just update your 只需更新你的

new Padding(padding: new EdgeInsets.all(10.0),

to

new Padding(padding: new EdgeInsets.all(1.0),

and see the change. 并看到变化。

If you don't want any spaces in between, you can directly return Card(); 如果您不希望介于两者之间,可以直接返回Card();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM