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, ),
)
You can use the Flexible
widget:
According to the docs:
A widget that controls how a child of a
Row
,Column
, orFlex
flexes.Using a
Flexible
widget gives a child of aRow
,Column
, orFlex
the flexibility to expand to fill the available space in the main axis (eg, horizontally for aRow
or vertically for aColumn
),
Container(
child: Row(
children: <Widget>[
Flexible(
child: Text(strTips, style: TextStyles.knowYourImpact, ))
],
));
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.