【问题标题】:Flutter : How to remove space between row in ListviewFlutter:如何在 Listview 中删除行之间的空间
【发布时间】:2018-10-07 23:15:34
【问题描述】:

我只是在做一些颤振的演示,我喜欢这样做,在列表视图中,我不知道如何删除行之间的空间

我的代码很简单,这个是小部件,我返回到我的布局

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())
        ],
      ),
    ),
);

}

这个是Listview

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

这是我使用卡片视图的行

 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: () { /* ... */ },
                    ),
                  ],
                ),
              ),
            ],
          ),
        )
    );
  }

帮帮我。

【问题讨论】:

    标签: listview dart flutter flutter-layout


    【解决方案1】:

    卡片之间的空格来自 getRow() 方法。

    更新你的

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

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

    看看变化。

    如果不想中间有空格,可以直接返回 Card();

    【讨论】:

      猜你喜欢
      • 2019-03-26
      • 2019-10-10
      • 2019-02-25
      • 2019-12-08
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多