daohoangson / flutter_widget_from_html

Flutter package to render html as widgets that supports hyperlink, image, audio, video, iframe and many other tags.
https://pub.dev/packages/flutter_widget_from_html
MIT License
635 stars 235 forks source link

HtmlWidget does not have a maxLines property. How can I set a maximum of 2 lines for the entire HTML content? #1317

Open ShahkhalidShaikh opened 1 month ago

ShahkhalidShaikh commented 1 month ago

if (element.localName == 'h1' || element.localName == 'h2' || element.localName == 'h3' || element.localName == 'h4' || element.localName == 'h5' || element.localName == 'h6' || element.localName == 'span' || element.localName == 'strong' || element.localName == 'sup' || element.localName == 'figure' || element.localName == 'body' || element.localName == 'p') { return Text( element.text, maxLines: 2, overflow: TextOverflow.ellipsis, style: textStyle, );``

daohoangson commented 2 weeks ago

You need to use inline CSS to control the number of lines. However, it will not work if the HTML itself contains block-level elements because their layout is incompatible with line logic.