insertBefore method

  1. @override
void insertBefore(
  1. Bs4Element element, [
  2. Bs4Element? ref
])

Inserts an element immediately before the current element in the parse tree.

ref specifies an position of an element, where should the insertion apply.

If the ref is not in the parse tree, throws RangeError.

If you want to pass Node instead Bs4Element, you can do it via bs4element.element.insertBefore(node, nodeRef).

Implementation

@override
void insertBefore(Bs4Element element, [Bs4Element? ref]) {
  if (ref == null) {
    insert(0, element);
  } else {
    _element.insertBefore(element._element, ref._element);
  }
}