How to add `overflow` to SelectableText in Flutter?

895

Just experienced this. The problem is overflow hasn't been made the top level parameter in case of SelectableText as with Text in Flutter which suggests that it must be there, just not as the top level parameter which is true as it is in TextStyle.

Hence, to use overflow in SelectableText, change

SelectableText(
  text,
  overflow: TextOverflow.ellipsis
)

to

SelectableText(
  text,
  style: TextStyle(
    overflow: TextOverflow.ellipsis,
  ),
)
Share:
895
Andriy Antonov
Author by

Andriy Antonov

Updated on December 29, 2022

Comments

  • Andriy Antonov
    Andriy Antonov about 1 year

    There is SelectableText widget that allows you to make text selectable. But it misses the overflow parameter, which is required...

    Is there any workaround, which can make it work? Or a similar solution? Thanks!

    • KuKu
      KuKu almost 3 years
      I think that all text should be shown to select text.
    • KuKu
      KuKu almost 3 years
      If you use 'maxLines' parameter, you can limit vertical spread.
    • Andriy Antonov
      Andriy Antonov almost 3 years
      @kuku not exactly. it will limit the number of lines, but they will become scrollable, which is terrible...