nextElement property
The nextElement is an element that was parsed immediately afterwards (firstly searches next elements of children, if empty then nextSiblings).
Use nextParsed if you want to get any type (doc comment, part of string, ...).
Implementation
@override
Bs4Element? get nextElement {
// find within children
final children = this.children;
if (children.isNotEmpty) {
return children.first;
}
// find within next sibling
final nextSibling = this.nextSibling;
if (nextSibling != null) {
return nextSibling;
}
// find within parent and next siblings
var parent = this.parent;
while (parent != null) {
if (parent.nextSibling == null) {
parent = parent.parent;
} else {
return parent.nextSibling;
}
}
return null;
}