У меня проблема с изменением типа Stepper с вертикального на горизонтальный.
Это мой код:
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.
Вы можете использовать виджет SizedBox() или Container() и установить его высоту
SizedBox(
height: 200,
child: 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,
),
)),
)
Ваш ListView имеет неограниченную высоту, поэтому он не знает, сколько места нужно использовать для каждого ребенка, который является Stepper.
Дайте ему некоторые ограничения, такой минимальный размер высоты для каждого, и все будет в порядке.
(...)
ConstrainedBox(
constraints: BoxConstraints.tightFor(height: 200.0),
child: Stepper(
steps: my_steps(),
type: StepperType.horizontal,
(...)