【问题标题】:Unwanted gap between items in Listview flutterListview 中的项目之间不想要的间隙颤动
【发布时间】:2019-03-13 12:30:07
【问题描述】:

我有一个列表视图,其内容是动态的。 Listview 用于显示动态小部件的列表。 使用以下代码填充 Listview

new Container(
      color: Colors.white,
      child:
      new ListView(
        padding: EdgeInsets.all(0.0),
        children: _widgetsList.map((Widget item){
          return new Container(
            color: Colors.red,
            child: item,
          );
        }).toList(),
      ),
);

输出如下图

问题是列表视图中的每个项目之间出现了一个非常小的间隙,我想将其删除。

等待您的帮助!

【问题讨论】:

  • 类似问题,尚待回答。 Flutter : Weird gap between items of ListView
  • child: item,: 你的 Listview 中的项目是什么样的 Widget?
  • 请添加商品代码
  • 项目是定制的小部件。
  • 关于这个问题的任何更新?

标签: listview dart flutter divider


【解决方案1】:

试试这个

class Item extends StatelessWidget {
  const Item({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(children: [
      Text(
    'YOUR TITLE',
    style: TextStyle(fontWeight: FontWeight.bold),
      ),
      Text('youremail@mail.com'),
      Text('Ph. 9494949494949'),
    ]);
  }
}


new Container(
      color: Colors.white,
      child:
      new ListView(
        padding: EdgeInsets.all(0.0),
        children: _widgetsList.map((Widget item){
          return new Container(
            color: Colors.red,
            child: Item(),
          );
        }).toList(),
      ),
);

【讨论】:

    猜你喜欢
    • 2019-12-29
    • 1970-01-01
    • 1970-01-01
    • 2016-06-19
    • 2020-10-03
    • 2013-02-22
    • 2017-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多