gpt4 book ai didi

android - Flutter展开竖线

转载 作者:IT王子 更新时间:2023-10-29 06:54:58 25 4
gpt4 key购买 nike

我有一个 ListView,我需要在它的左侧有一条展开的垂直线(请参见下图)。我实现了以下布局,但它扩展到无限。

Line expanding to infinite

下面是上述布局的代码:

return Scaffold(
...
body: Column(
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 4.0),
color: Colors.grey,
width: 4.0,
child: SizedBox.expand(),
),
Flexible(
child: StreamBuilder( // Creates the list view
stream: ...,
builder: ...,
),
),
],
),
],
),
};

由于 SizedBox.expand() 而使行变得无限,但如何适应屏幕。有什么建议吗?

或者有没有办法从 ListView 项(没有固定大小)获得同样的效果。

最佳答案

如果您只有一个 child ,请不要使用 Column 作为 Parent,这对我有用:

  return Container(
child: Row(
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 4.0),
color: Colors.grey,
width: 4.0,
),
Expanded(
child: ListView.builder(
// Creates the list view
shrinkWrap: true,
itemCount: list.length,
itemBuilder: (context, index) {
return ListTile(
contentPadding: EdgeInsets.all(20.0),
title: Text(list[index].toString()),
);
},
),
),
],
),
);

关于android - Flutter展开竖线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51876613/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com