insertBefore method

void insertBefore(
  1. ChildNode node, {
  2. ChildNode? before,
})

Inserts node before before, or at the end if before is null.

Otherwise the same as insertAfter.

Implementation

void insertBefore(ChildNode node, {ChildNode? before}) {
  if (_prepareInsert(node, before) case final list?) {
    list._link(node, before == null ? list._last : before._prev, before);
  }
}