htmlBody method

Widget htmlBody(
  1. dynamic text,
  2. dynamic context, {
  3. dynamic color,
  4. LineHeight? height,
  5. int? maxLines,
})

Implementation

Widget htmlBody(text, context, {color, LineHeight? height, int? maxLines}) {
  return Html(
    data: text,
    style: {
      "body": Style(
        maxLines: maxLines,
        color: color ?? Theme.of(context).textTheme.bodyMedium!.color,
        padding: HtmlPaddings.all(0),
        margin: Margins.zero,
        textOverflow: maxLines != null ? TextOverflow.ellipsis : null,
        lineHeight: LineHeight(textHeight),
      ),
      "html": Style(padding: HtmlPaddings.all(0), margin: Margins.zero),
      "div": Style(
          padding: HtmlPaddings.all(0),
          backgroundColor: Colors.transparent,
          fontFamily: Theme.of(context).textTheme.bodyMedium!.fontFamily,
          fontWeight: regularWeight,
          color: color ?? Theme.of(context).textTheme.bodyMedium!.color,
          lineHeight: height ?? LineHeight(textHeight),
          fontSize: FontSize(regularText)),
      "ul": Style(
        listStyleType: ListStyleType.disc,
      ),
      "p": Style(
        fontSize: FontSize(regularText),
        lineHeight: height ?? LineHeight(textHeight),
        color: color ?? Theme.of(context).textTheme.bodyMedium!.color,
      ),
      "small": Style(fontSize: FontSize(smallText)),
      "a": Style(
          color: Theme.of(context).colorScheme.primary,
          fontSize: FontSize(smallText))
    },
    onLinkTap: (url, v1, v2) async {
      await Utils.launchUrl(url);
    },
  );
}