How to render HTML Tags in Flutter and limit the number of lines

Viewed 4114

I want to limit the number of lines and render html tags in flutter right now i am using Text widget and limiting the number of lines. The problem is i am getting html tags in my rest full api so i want to render these tags. I tried flutter html package but there is no option to limit the number of lines. Thanks

 Container(
  padding: EdgeInsets.symmetric(horizontal:10.0),
  margin: EdgeInsets.only(bottom:10.0),
  child: Text(
    widget.description,
    style:plpDescriptionTextstyle,
    maxLines: 4,
      ),
   ),
2 Answers

You can use styles in this library:

Html(
  data: 'Your text with html tag',
  style: {
    '#': Style(
      fontSize: FontSize(18),
      maxLines: 10,
      textOverflow: TextOverflow.ellipsis,
    ),
  },
),

After searching hours i came to this solution incase if someone is facing same issue.

Container(
    padding: EdgeInsets.symmetric(horizontal:2.0),
    margin: EdgeInsets.only(bottom:10.0),
    child:
          Html(
             data:  widget.description.substring(0, 90)+'..'
             ),
       ),
Related