I have a Container with maximum width and I dont want to have additional free space after words. It works fine with small words like this . But with long words i have additional free space and my line looks like that . What can I do?
Here is my code:
Container(
constraints: BoxConstraints(maxWidth: size.width * 0.4),
padding: EdgeInsets.only(right: size.width * 0.015),
//color: Colors.red,
child: Text(
"Generics",
style:
TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
)),
Try using a
FittedBox
. It will make sure that it's children have the givenfit
.Here is an example from flutter.dev:
Read more here.