Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display html text in flutter?

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

like image 257
Vithani Ravi Avatar asked Feb 12 '19 07:02

Vithani Ravi


2 Answers

There are packages that do this

  • https://pub.dartlang.org/packages/webview_flutter inline browser view

  • https://pub.dartlang.org/packages/flutter_html renders a HTML subset in Flutter directly

like image 108
Günter Zöchbauer Avatar answered Oct 27 '22 15:10

Günter Zöchbauer


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),
       ),
     ],
)
like image 30
Techalgoware Avatar answered Oct 27 '22 13:10

Techalgoware