gpt4 book ai didi

dart - Flutter Stepper 卧式不工作

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

我在将步进器类型从垂直更改为水平时遇到问题。

这是我的代码:

body: new ListView.builder(
itemCount: data == null ? 0 : 5,
itemBuilder: (BuildContext context, int index) {
return new Card(
//child: new Text(data[index]["title"]),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Stepper(
steps: my_steps,
type: StepperType.horizontal,
controlsBuilder: (BuildContext context,
{VoidCallback onStepContinue, VoidCallback onStepCancel}) {
return Row(
children: <Widget>[
Container(
child: null,
),
Container(
child: null,
),
],
);
},
//type: StepperType.horizontal,
),
));
},
),

在我取消对类型的注释后,我得到了这个错误:

I/flutter (10148): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════ I/flutter (10148): The following assertion was thrown during performLayout(): I/flutter (10148): RenderFlex children have non-zero flex but incoming height constraints are unbounded. I/flutter (10148): When a column is in a parent that does not provide a finite height constraint, for example if it is I/flutter (10148): in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a I/flutter (10148): flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining I/flutter (10148): space in the vertical direction.

最佳答案

您的 ListView 的高度是无限的,所以它不知道为每个子项(一个 Stepper)使用多少空间。给它一些限制,例如每个限制的最小高度,你应该没问题。

 (...)
ConstrainedBox(
constraints: BoxConstraints.tightFor(height: 200.0),
child: Stepper(
steps: my_steps(),
type: StepperType.horizontal,
(...)

关于dart - Flutter Stepper 卧式不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54856081/

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