1

I am displaying Tooltip on top of a Text, letting user see the full name of person, but it shows Tooltip, either when text has overflown or not:

child: Tooltip(
                message: fullNameWithTitle,
                child: Text(
                  fullNameWithTitle,
                  style: const TextStyle(
                    color: Colors.white,
                  ),
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                  textAlign: TextAlign.center,
                ),
              ),

But how can I set Tooltip in such a way that displays just if text is trimmed by ellipsis?

AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
  • I think this will help using flutter plug-in auto_size_text https://stackoverflow.com/a/60637243/11445727 – Fahmida Feb 13 '22 at 06:05
  • Hi, I didn't get your question well, Specially "either when text has overflown or not:" part, Can you elaborate please? I think I can help you with this case. – Devarsh Ranpara Feb 13 '22 at 06:20
  • I have the same question, so to elaborate: The goal is to be able to display a tooltip only when the text overflows. If the complete text is displayed, no need to display a tooltip. In many cases as mine, for example text displayed in cells of a table, you don't want to reduce font size like a plug like plug-in auto_size_text will do, because it will create a visual imbalance with others texts elements. I've seen lot of solutions for classical html/css/js environnement, but I can't find any solution for now for flutter... – BenDev Mar 28 '23 at 13:01

0 Answers0