0

How to control TextOverFlow if don't know the const width of the box. I know about

Text(
      'some Text',
      overflow: TextOverflow.ellipsis,
)

but is there any way to wrap widgets like expanded or flexible?

Ali Azimoshan
  • 1,081
  • 11
  • 26
  • https://stackoverflow.com/questions/44579918/flutter-wrap-text-on-overflow-like-insert-ellipsis-or-fade – AL.Sharie Mar 08 '21 at 07:40
  • I think you have state the solution itself, which is using `Flexible` with `overflow` attributes to control the text overflow. It's better if you can clarify the problem that prevented you from using these widgets, what went wrong or if any error came up. – Bach Mar 08 '21 at 10:29
  • @Bach that's right, but it not work with Flexible, for that, I need to wrap it in a container and again give it width. – Ali Azimoshan Mar 08 '21 at 10:51
  • @AliAzimoshan Thanks for clarify Ali. Can you give us more code of your current implementation of `Flexible`, maybe the screen that contains it? It's easier to pinpoint the issue – Bach Mar 08 '21 at 10:59

2 Answers2

0
FittedBox(
      fit: setToWidth ? BoxFit.contain : BoxFit.none,
      child: Text(
        displayText,
        maxLines: 2,
        textAlign: textAlign,
        style: setToWidth
            ? TextStyle(
                fontWeight: fontWeight,
                color: textColor,
                fontFamily: AppFonts.circularStd,
              )
            : TextStyle(
                fontWeight: fontWeight,
                color: textColor,
                fontFamily: AppFonts.circularStd,
                fontSize: textSize),
      ),
    );

Try with this

ayesh don
  • 1,121
  • 1
  • 15
  • 25
0

You can try AutoSizeText instead. https://pub.dev/packages/auto_size_text

Note: it'll increase your overall app size as it requires external dependencies. But it'll give you some extra features such as maxLines and minLines. I will suggest read more about it.