简体   繁体   中英

How to give to a Flutter container the Height equivalent to the child and children inside himself

how it is possible to give to the container height the right height of the equivalent of the total children inside this container? this is my piece of code:


child: Container(
          height: ????,<----HERE TO BE IMPLEMENT HEIGHT
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              SizedBox(height: 15,),
              SearchWidget(),
              Padding(
                padding: const EdgeInsets.fromLTRB(12, 15, 0, 8),
                child: Text('Le offerte del Momento',style: TextStyle(color: Color(0xff494949),fontWeight: FontWeight.w500),),
              ),
              

To get the height of the child use IntrinsicHeight:

Container(
        child: IntrinsicHeight(
                        child: Column(
...

But as it was said in the comments, unless you need some properties of the Container like a decoration for example, you shouldn't use a Container because it is useless in this case. Just add mainAxisSize: MainAxisSize.min to your column so that its size depends on those of children.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM