toTextSpan static method

TextSpan toTextSpan(
  1. BuildContext context,
  2. String htmlContent, {
  3. Function linksCallback = defaultLinksCallback,
})

Returns a TextSpan object you can directly pass to a RichText widget. In addition to the build context and your HTML content, you can pass a function to this method. You can use the function to handle click events on anchor tags. The function will receive the actual link as its argument.

Implementation

static TextSpan toTextSpan(BuildContext context, String htmlContent,
    {Function linksCallback = defaultLinksCallback}) {
  Parser p = Parser(context, htmlContent, linksCallback: linksCallback);
  return TextSpan(text: "", children: p.parse());
}