adjust method

  1. @override
void adjust()
override

Implementation

@override
void adjust() {
  if (isEmpty) {
    final sibling = previous;
    unlink();
    if (sibling != null) {
      sibling.adjust();
    }
    return;
  }

  var block = this;
  final prev = block.previous;
  // merging it with previous block if style is the same
  if (!block.isFirst &&
      block.previous is Block &&
      prev!.style == block.style) {
    block
      ..moveChildToNewParent(prev as Container<Node?>?)
      ..unlink();
    block = prev as Block;
  }
  final next = block.next;
  // merging it with next block if style is the same
  if (!block.isLast && block.next is Block && next!.style == block.style) {
    (next as Block).moveChildToNewParent(block);
    next.unlink();
  }
}