Issue
I have a very long string which I get from the user. However, the string does not utilize the space to the right. Is there any way by which the string will be hyphenated when reached at the end of its space and ONLY THEN go to the next line?
Here is my code:
Widget getIconWithDesc (IconData iconData, Color iconColor) {
return Flexible(
child: Row(
children: [
Flexible(flex: 2, child: Icon(iconData, size: 60.0, color: iconColor)),
const Flexible(flex: 1, child: SizedBox(width: 10.0,)),
Flexible(flex:1, child: Text(widget.desc)),
],
),
);}
I added the Flexible widget since the text was otherwise overflowing from the screen. However, though this prevented overflowing, the String doesn't take up space on the right. I tried to mess around with the flex values, but no luck.
Solution
Try Fitted Box instead Flexible. This may make your text smaller.
Widget getIconWithDesc (IconData iconData, Color iconColor) {
return Row(
children: [
FittedBox(flex: 2, child: Icon(iconData, size: 60.0, color: iconColor)),
const Flexible(flex: 1, child: SizedBox(width: 10.0,)),
Flexible(flex:1, child: Text(widget.desc)),
],
);}
Answered By - Harsh Sureja
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.