4

我正在尝试生成嵌套在 VERTICAL 列表视图中的动态高度水平列表视图

我已经在打印我的水平列表视图了,但是每张卡片的内容都被水平列表视图的父容器的固定高度切割,由于父容器,关闭动画也被切割了水平列表视图的高度

class TestPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Test'),
      ),
      body: ListView(
        children: <Widget>[
          Container(
            height: 100,
            child: ListView.builder(
              scrollDirection: Axis.horizontal,
              itemCount: 100,
              itemBuilder: (context, index) {
                return Dismissible(
                  direction: DismissDirection.down,
                  key: Key('$index'),
                  child: Card(
                    child: Container(
                      width: 100,
                      child: Text('${index}',
                        // here goes cutted long text
                        style: TextStyle(color: Colors.white),
                      ), 
                    ),
                  ),
                );
              },
            ),
          ),
        ],
      ),
    );
  }
}

链接图片,https ://i.pinimg.com/564x/b7/f6/34/b7f6340dbb96212bc9c216e9bbc0d5da.jpg,stackoverflow 还不允许我发布图片:(

*编辑:我寻找的是根据其子文本的长度动态设置每个卡片的高度

4

1 回答 1

0

与其将嵌套列表视图放在容器中,不如尝试用 Expanded 小部件包装它?

于 2019-08-13T17:33:21.477 回答