Skip to content
pubscout

simple_html_css

5.0.0, released 3 years ago by an unverified publisher

Convert simple HTML and inline CSS styles into RichText or TextSpan widgets.

WASM-ready
$ flutter pub add simple_html_css
Source repository

What it does

Parses HTML strings with inline CSS and transforms them into Flutter RichText or TextSpan widgets. Supports common text formatting tags like headings, bold, italic, links, and text-related CSS properties such as color, font-size, and font-weight.

AI-written summary of version 5.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to render basic HTML-formatted text with inline styles inside a Flutter app.
  • You want to handle link clicks embedded inside rich text content.

Skip it when

  • You need a full web browser view to render complex HTML layouts, JavaScript, or external stylesheets.
  • You require full support for ordered and unordered lists with custom numbering or symbols.

Strengths

  • Easy to use with simple static methods like HTML.toRichText() and HTML.toTextSpan().
  • Allows custom global text styling and overriding styles per HTML tag.
  • Provides a callback mechanism for handling links within the HTML content.

Weaknesses

  • Lists (<ol>, <ul>, <li>) are only partially supported without numbers or symbols.
  • Input HTML content must be unescaped before passing into version 5.0.0+.
  • Only handles text-related CSS properties and tags.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1

Requires Flutter version >= 3.22. Input strings must be unescaped prior to parsing.

String htmlContent = "<p style='font-size:1.5em;'>Hello World</p>";

RichText(
  text: HTML.toTextSpan(context, htmlContent),
  maxLines: 4,
);

Alternatives

Packages that do the same job and could replace simple_html_css.

Works with

Packages commonly used together with simple_html_css: ones it builds on, ones built on it, and its own family.