styleTree static method

StyledElement styleTree(
  1. StyledElement tree,
  2. Element htmlData,
  3. Map<String, Style> style,
  4. OnCssParseError? onCssParseError,
)

styleTree takes the lexed StyleElement tree and applies external, inline, and custom CSS/Flutter styles, and then cascades the styles down the tree.

Implementation

static StyledElement styleTree(StyledElement tree, dom.Element htmlData,
    Map<String, Style> style, OnCssParseError? onCssParseError) {
  Map<String, Map<String, List<css.Expression>>> declarations =
      _getExternalCssDeclarations(
          htmlData.getElementsByTagName("style"), onCssParseError);

  StyledElement? externalCssStyledTree;
  if (declarations.isNotEmpty) {
    externalCssStyledTree = _applyExternalCss(declarations, tree);
  }
  tree = _applyInlineStyles(externalCssStyledTree ?? tree, onCssParseError);
  tree = _applyCustomStyles(style, tree);
  tree = _cascadeStyles(style, tree);
  return tree;
}