Reputation:
In Android, we can use AutoResizeTextView
and give it any text size of our choice, it will not flow out of its constraints, I was looking for similar solution in Flutter.
I tried following,
Container(
color: Colors.blue,
constraints: BoxConstraints(maxHeight: 200.0, minWidth: 600.0),
child: Text("8", style: TextStyle(fontSize: 400.0)),
);
Here is the ugly output. So, how can I force the Text
to always stay inside the Container
no matter how much fontSize
is given to it
Upvotes: 0
Views: 72
Reputation:
I need to wrap the Text
inside FittedBox
which is further wrapped inside a Container
. Here is the solution.
Container(
color: Colors.blue,
constraints: BoxConstraints(maxHeight: 200.0, minWidth: 600.0),
child: FittedBox(child: Text("8", style: TextStyle(fontSize: 400.0))),
);
Upvotes: 1