Flutter:Step widget无法容纳Expanded

w8f9ii69  于 2023-05-23  发布在  Flutter
关注(0)|答案(1)|浏览(215)
Widget stepPickerData(BuildContext context, SwapRequest snapData) {
final makeSwapRequestBloc = MakeSwapRequestProvider.of(ctx);
Widget child1 = Container(
child: Column(
   children: <Widget>[
     Expanded(
       child:  ListTile(title: Text("w"),)
      )
    ],
  ),
);
List<Step> mySteps = [
  new Step(
    // Title of the Step
      title: Text("Step 1"),
      content: child1,
      isActive: true),
  new Step(
      title: new Text("Step 2"),
      content: child2,
      isActive: true),
];
return new Container(
  child: new Stepper(
    currentStep: this.currentStep,
    steps: mySteps,
    type: StepperType.horizontal,
    onStepContinue: () {
       if (currentStep < mySteps.length - 1) {
        currentStep = currentStep + 1;
      } else {
        currentStep = currentStep;
      }
    },
  ),
 );
}

我有步进器部件的步骤和步骤部件组成扩展的孩子。扩展的孩子不是在步骤部件举行。
抛出的错误是:
RenderFlex子对象具有非零的flex,但传入的高度约束是无边界的。

p5cysglq

p5cysglq1#

Expanded小部件应该是具有确定高度的小部件的后代。这就是为什么你得到一个"height constraints are unbounded"错误的原因。您可以应用的解决方法是在Widget上定义一个高度。如果需要扩展Widget,可以使用BoxContstraints

/// IntrinsicHeight allows the Widget fit according to the displayed data
IntrinsicHeight(
  child: ConstrainedBox(
    constraints: BoxConstraints(
        // Define min and max height as needed
        // maxHeight: Constants.minHeight,
        minHeight: Constants.minHeight,
      ),
      child: Container(
        // add child widgets here
      ),
    ),
  ),
),

相关问题