I’m using TextOverflow.ellipsis and have the following issue:
Text(
'This is an example of a string that needs an ellipses',
overflow: TextOverflow.ellipsis,
)
Obviously it depends on the size of the Text widget and the font, etc, but when given the correct parameters the result will look like:
'This is an example of a string ...'
where I want it to look like this, ignoring the final blank space:
'This is an example of a string...'
Would appreciate any ideas how this might be achieved.
2
Answers
By using
inputText.trim()
, you ensure that any leading or trailing whitespace is removed from the string before it is displayed in the Text widget withTextOverflow.ellipsis
. This will result in the desired output where the ellipsis follows the last non-whitespace character without any extra spaces.