previousSibling property Null safety

XmlNode? previousSibling

Return the previous sibling of this node, or null.

Implementation

XmlNode? get previousSibling {
  if (parent != null) {
    final siblings = parent!.children;
    for (var i = siblings.length - 1; i > 0; i--) {
      if (identical(siblings[i], this)) {
        return siblings[i - 1];
      }
    }
  }
  return null;
}