0

I have managed to limit html content by using maxlines property of Style and display "show more" text in case the content overflows the maxlines value.

Html( data: notifications[index] .longDescription, shrinkWrap: true, style: { 'body': Style( maxLines: notifications[ index] .isExpaned ? 10000 : 2, textOverflow: TextOverflow .ellipsis) }),

Now the problem is to detect if the widget has overflowed or not because i have to hide "view more" option in case the content is less than 2 lines.

Can anyone suggest any alternate way of getting List of TextSpan in flutter_html^2.1.0 so that I can use that list like this

enter image description here

Nadeem Haider
  • 160
  • 1
  • 12
  • 1
    You can check this similar answer here: [hasTextOverflow method](https://stackoverflow.com/a/65408733/14269222) – Suat Özkaya Jun 21 '21 at 14:11
  • @SuatÖzkaya thanks for your reply! This answer is using plain text whereas in my scenario I am working on text from Html widget which is not plain text. – Nadeem Haider Jun 24 '21 at 04:56
  • 1
    Also, there is a package called [readmore](https://pub.dev/packages/readmore). A Flutter plugin than allow expand and collapse text. Maybe someone reading here can find it useful. – Suat Özkaya Jun 28 '21 at 12:06

0 Answers0