6

I have to display html text as like android provides Html.fromHtml to display htmltextview does flutter provides anythings to display html text?

Vithani Ravi
  • 1,807
  • 3
  • 13
  • 19

2 Answers2

7

There are packages that do this

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
2

Add the following to your pubspec.yaml file:

dependencies:
  flutter_html:

Currently Supported HTML Tags:

a, abbr, acronym, address, article, aside, b, bdi, bdo, big, blockquote, body, br, caption, cite, code, data, dd, del, dfn, div, dl, dt, em, figcaption, figure, footer, h1, h2, h3, h4, h5, h6, header, hr, i, img, ins, kbd, li, main, mark, nav, noscript, ol, p, pre, q, rp, rt, ruby, s, samp, section, small, span, strike, strong, sub, sup, table, tbody, td, template, tfoot, th, thead, time, tr, tt, u, ul, var

Example Usage:

Column(
   mainAxisAlignment: MainAxisAlignment.start,
   crossAxisAlignment: CrossAxisAlignment.start,
   children: [
      new Html(
         data: "<b>Hai</b>,
          defaultTextStyle: TextStyle(fontSize: 15),
       ),
     ],
)
Techalgoware
  • 540
  • 6
  • 11
  • 1
    This is great if you want to hard code your html into your app, but if you're pulling from firestore and you need different styling for different documents (or if you want to make your text selectable), this plugin does not work. – ddonche Nov 11 '20 at 19:43