Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic height Container based on Child Text widget

I want to achieve dynamic container height based on child Text widget. Text String received from server and dynamic. So whenever I fetch it that should seen properly inside Container. I have used following code:

Container(
  width:  MediaQuery.of(context).size.width*.93,
  height:  MediaQuery.of(context).size.height*.20,
  child: Text(strTips, style: TextStyles.knowYourImpact, ),
 )

For reference I am adding image. enter image description here

like image 907
Code Hunter Avatar asked Sep 15 '26 23:09

Code Hunter


1 Answers

You can use the Flexible widget:

According to the docs:

A widget that controls how a child of a Row, Column, or Flex flexes.

Using a Flexible widget gives a child of a Row, Column, or Flex the flexibility to expand to fill the available space in the main axis (e.g., horizontally for a Row or vertically for a Column),

Container(
    child: Row(
         children: <Widget>[
            Flexible(
                child: Text(strTips, style: TextStyles.knowYourImpact, ))
             ],
         ));
like image 200
Peter Haddad Avatar answered Sep 19 '26 00:09

Peter Haddad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!