Using `BoxFit.scaleDown` and fixing the FontSize you can adjust the maximum size of the font.
Normal purpose use below code
Flexible(
child: FittedBox(
fit: BoxFit.contain,
child: AutoSizeText(
'your specific text',
maxLines: 1,
style: TextStyle(),
),
),
),
If the content is small, it occupies the minimum width with the specified font size. At the same time, if the content is large, it resizes to the smallest font size.
FittedBox(
fit: BoxFit.scaleDown,
child:
Text(
"Text here",
style: TextStyle(fontSize: 18),
),)
If you need the text to fill the entire width, using any font size use `BoxFit.cover`
FittedBox(
fit: BoxFit.cover,
child:
Text(
"Text here",
//style: TextStyle(fontSize: 18),
),)
you can use this package in addition https://pub.dev/packages/auto_size_text
I used it this way and it worked perfectly:
Flexible(
child: FittedBox(
fit: BoxFit.contain,
child: AutoSizeText(
'your specific text',
maxLines: 1,
style: TextStyle(),
),
),
),
This gives us **flexibility** and ensures that our child widget is inside and behaving as expected (**containing**), in addition to using **[auto_size_text][1]**.
[1]: https://pub.dev/packages/auto_size_text