auto_size_text icon indicating copy to clipboard operation
auto_size_text copied to clipboard

Options for ways to use TextOverflow

Open behnamsattar opened this issue 6 years ago • 1 comments

Description When there is a TextOverflow option set, truncation happens in places where there is a space (or linebreak I guess). This is fine, but if we have a very long word at the end of the string, then that long word will be cut altogether which may cause the text to look weird (considering there is no resizing happening). For example, if I have this string "Hello Jack, hello Pauline, and finally Hello Fredrikhteshkesteandermastionisk", then if the truncation happens, the last long word will be all replaced with ellipses. This makes the text look weird in some places. In my specific use case, I have a container around the text which is sized with extra space in this case!

Proposed Solution The solution would have two parts: First of all, it would be great to put a wrapping setting, to determine what kind of truncation would happen if the overflow symbol is used. One option in the beforementioned example would replace the whole "Fredrikhteshkesteandermastionisk" with ellipses and the other option would use a part of the word in the final string with ellipses at the end, like "Fredrikhteshkestean...". The other part of the solution which I think could be also reported as a separate bug is regarding the size of the final Text. In the example above, considering the last word is replaced, the size of the Container around the text is not set based on the actual rendered text and seems to consider having a part of that last long word in there. So although the final result is shown as "Hello Jack, hello Pauline, and finally Hello ...", the Container around the text which should wrap around the text is sized bigger like if the text is "Hello Jack, hello Pauline, and finally Hello Fredrikhteshkeste...".

Alternatives I have not considered anything and for now, I'm living with it hoping that the text our users enter won't have a very long word where truncation happens.

Version

  • Flutter version: 1.12.13+hotfix.5
  • auto_size_text version: 2.1.0

behnamsattar avatar Jan 13 '20 19:01 behnamsattar

The other part of the solution which I think could be also reported as a separate bug is regarding the size of the final Text. In the example above, considering the last word is replaced, the size of the Container around the text is not set based on the actual rendered text and seems to consider having a part of that last long word in there. So although the final result is shown as "Hello Jack, hello Pauline, and finally Hello ...", the Container around the text which should wrap around the text is sized bigger like if the text is "Hello Jack, hello Pauline, and finally Hello Fredrikhteshkeste...".

Note that this is not an enhancement, and I think it is a bug as it makes the auto-size not work correctly.

behnamsattar avatar Feb 09 '22 19:02 behnamsattar