build method

  1. @override
Widget build(
  1. BuildContext context
)
override

As the widget builds, the HTML data is processed into a tree of StyledElements, which are then parsed into an InlineSpan tree that is then rendered to the screen by Flutter

Implementation

//TODO Lazy processing of data. We don't need the processing steps done every build phase unless the data has changed.
@override
Widget build(BuildContext context) {
  // Lexing Step
  StyledElement lexedTree = lexDomTree(
    htmlData,
    customRenders.keys.toList(),
    tagsList,
    context,
    this,
  );

  // Styling Step
  StyledElement styledTree =
      styleTree(lexedTree, htmlData, style, onCssParseError);

  // Processing Step
  StyledElement processedTree =
      processTree(styledTree, MediaQuery.of(context).devicePixelRatio);

  // Parsing Step
  InlineSpan parsedTree = parseTree(
    RenderContext(
      buildContext: context,
      parser: this,
      tree: processedTree,
      style: processedTree.style,
    ),
    processedTree,
  );

  return CssBoxWidget.withInlineSpanChildren(
    style: processedTree.style,
    children: [parsedTree],
    selectable: selectable,
    scrollPhysics: scrollPhysics,
    selectionControls: selectionControls,
    shrinkWrap: shrinkWrap,
  );
}