Reputation: 311
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),),
),
Upvotes: 0
Views: 2033
Reputation: 5
If a size factor is non-null then the corresponding dimension of this widget will be the product of the child’s dimension and the size factor. For example if widthFactor is 2.0 then the width of this widget will always be twice its child’s width.
This means that if we set heightFactor to 10, the height of the Center widget will become “10 * height of its child” i.e. “10 * height of Text widget”
Upvotes: 0
Reputation: 1407
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.
Upvotes: 3