skip to Main Content

Here is my code my booking status widget returns different kind of widgets based on the booking status. And each widget has it own height. So i want to wrap my booking status widget on something that will make its height fit depending to its content.

const Column(
  children: [
    // Map Area
    Expanded(
      child: GmapWidget(),
    ),

    // Booking Status Widget
    SizedBox(
      height: 330,
      child: BookingStatusWidget(),
    ),
  ],
),

I tried wrapping it in an expanded and flexible widget instead of using the sizedbox with 330 height. But i think there is a default height in those widget so it doesnt fit to the content and takes up larger space than the content of the child itself.

2

Answers


  1. Just wrap it with a Container without giving any height to it.

    The Container will expand according to its child widgets.

    Login or Signup to reply.
  2. I’m not sure, but you can try this.
    You can wrap your BookingStatusWidget with Container and give BoxConstraints constraints max height like this your container will shrink according to your widget given height.

        Container(
             constraints: BoxConstraints(
                maxHeight: double.infinity
              ),
              child: BookingStatusWidget(),        
        ),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search