simc / auto_size_text

Flutter widget that automatically resizes text to fit perfectly within its bounds.
https://pub.dev/packages/auto_size_text
MIT License
2.06k stars 241 forks source link

Option to add text by the end of the overflowed text and an action #33

Closed LeoVen closed 5 years ago

LeoVen commented 5 years ago

Many times a text overflows, I would still want to show the entire text either by opening it in a modal or another page.

Would be nice to have a three dots (or a custom text) by the end of the cut off text and an action (maybe a widget, maybe just a custom text with a custom onTap action). For example:

"This text is way too long because it will only take up to 64 le ... more"

The three dots by the end can be a custom text or icon and the "more" text can have an action to maybe open up some screen that can show the entire text. As mentioned above the "more" can also be a Widget, for possibly an Icon or custom Text.

An alternative for me was to add a button below the trimmed text for the user to open the entire text in a modal.

Version

simc commented 5 years ago

You can achieve all of that using the overflowReplacement parameter.

For example:

AutoSizeText (
  "Some long String",
  overflowReplacement: GestureDetector(
    onTap: () {
      // Open modal
    },
    child: AutoSizeText (
      "Some long String ... more",
    ),
  ),
)
LeoVen commented 5 years ago

Apparently the solution was right under my nose