2
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;
      }
    },
  ),
 );
}

I have stepper widget with steps and step widget consists Expanded child.The expanded child isnot hold in step widget.

The error throwing is:

RenderFlex children have non-zero flex but incoming height constraints are unbounded.

BINAY THAPA MAGAR
  • 4,017
  • 4
  • 16
  • 24
  • What is the layout that you are trying to achieve? Perhaps a diagram would help. – Derek Lakin Aug 06 '18 at 15:32
  • Its a simple stepper widget with listview.builder inside it. Step 1: select the date Step 2 : show the selected date. Thats it. Step 2 has a listview buider inside expanded widget. – BINAY THAPA MAGAR Aug 07 '18 at 02:44
  • The code you've shared doesn't include the `ListView` builder. `RenderFlex` layout issues are to do with a lack of constraints (in this case height) which prevents it from working out how to lay out and size the widgets. It will be important to have the full widget tree in order to provide a complete answer. – Derek Lakin Aug 07 '18 at 13:01
  • Also, the overall layout that you're trying to achieve is important; what's in the ListView, how many items, etc? What are you trying to achieve by using `Expanded` (which is part of the cause of the error you're seeing)? – Derek Lakin Aug 07 '18 at 13:49
  • Thnank you derek for the lovely response. Here is the link for my widgets overview https://pasteboard.co/HyavrFs.png – BINAY THAPA MAGAR Aug 08 '18 at 04:31
  • So, the intent is to have a `DatePicker` at the top of the step and the selected dates fill up from the bottom of the screen and an `Expanded` to fill the space between? What happens when so many dates are picked that the screen fills and overflows? Or is there a limit to the number of dates that can be picked? – Derek Lakin Aug 09 '18 at 07:34
  • No there is no limit. Expanded widget holds list builder where all dates are listed out. – BINAY THAPA MAGAR Aug 09 '18 at 08:21
  • OK, so if the list just keeps growing, what do you need the `Expander` for? – Derek Lakin Aug 09 '18 at 11:03
  • yes exactly right – BINAY THAPA MAGAR Aug 09 '18 at 15:41
  • Sorry, maybe I didn't explain myself properly. If the list just keeps growing and would eventually scroll, what purpose does the `Expander` serve? Why not just put the `ListView` directly under the `DatePicker`? (As an aside, I believe that Stepper naturally scrolls, so rather than use a `ListView`, you can just use a `Column`) – Derek Lakin Aug 09 '18 at 16:03

1 Answers1

0

Expanded widget should be a descendant of Widget with definite height. That's the reason why you're getting a "height constraints are unbounded" error. A workaround that you can apply is to define a height on the Widget. If you need the Widget to expand, you can use 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
      ),
    ),
  ),
),
Omatt
  • 8,564
  • 2
  • 42
  • 144