generate method

T? generate(
  1. DOMNode root, {
  2. DOMTreeMap<T>? treeMap,
  3. T? parent,
  4. DOMContext<T>? context,
  5. bool finalizeTree = true,
  6. bool setTreeMapRoot = true,
})

Generates an element T using root.

treeMap Tree to populate. If null calls createGenericDOMTreeMap to define DOMTreeMap instance. context Optional context for this generated tree. parent Optional parent to add the generated element. finalizeTree Default true: calls finalizeGeneratedTree.

Implementation

T? generate(DOMNode root,
    {DOMTreeMap<T>? treeMap,
    T? parent,
    DOMContext<T>? context,
    bool finalizeTree = true,
    bool setTreeMapRoot = true}) {
  treeMap ??= createGenericDOMTreeMap();
  context ??= _domContext;

  if (setTreeMapRoot) {
    treeMap.setRoot(root, null);
  }

  var rootElement = build(null, parent, root, treeMap, context);

  if (setTreeMapRoot) {
    treeMap.setRoot(root, rootElement);
  }

  _callFinalizeGeneratedTree(treeMap, context, finalizeTree);

  return rootElement;
}