nextElementSibling property Null safety

Element? nextElementSibling

Implementation

Element? get nextElementSibling {
  final parentNode = this.parentNode;
  if (parentNode == null) return null;
  final siblings = parentNode.nodes;
  for (var i = siblings.indexOf(this) + 1; i < siblings.length; i++) {
    final s = siblings[i];
    if (s is Element) return s;
  }
  return null;
}