Search code examples
fluttertextjquery-ui-selectable

How to add `overflow` to SelectableText in Flutter?


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!


Solution

  • 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,
      ),
    )