backwardCopy static method

ChildLayoutDryDelegate? backwardCopy(
  1. ChildLayout? lastChild,
  2. LayoutHandle<Layout> layoutHandle
)

Creates a backward-linked chain of dry layout delegates.

Starting from lastChild, creates a linked list of delegates in reverse order. Returns the last delegate in the chain, or null if lastChild is null.

Implementation

static ChildLayoutDryDelegate? backwardCopy(
  ChildLayout? lastChild,
  LayoutHandle<Layout> layoutHandle,
) {
  ChildLayoutDryDelegate? first;
  ChildLayoutDryDelegate? last;
  ChildLayout? child = lastChild;
  while (child != null) {
    final delegate = ChildLayoutDryDelegate(child, layoutHandle.setupCache());
    if (last == null) {
      last = delegate;
      first = delegate;
    } else {
      first!.previousSibling = delegate;
      delegate.nextSibling = first;
      first = delegate;
    }
    child = child.previousSibling;
  }
  return last;
}