addBlockAtDepth method
Implementation
CrawledBlock addBlockAtDepth(CrawledBlock block, int depth) {
assert(depth >= 0);
assert(depth == 0 || nestedBlocks.isNotEmpty);
if (depth == 0) {
return copyWith(
nestedBlocks: [...nestedBlocks, block],
);
}
return copyWith(
nestedBlocks: [
...(nestedBlocks.length > 1
? nestedBlocks.sublist(0, nestedBlocks.length - 1)
: []),
nestedBlocks.last.addBlockAtDepth(block, depth - 1),
],
);
}