previousElementSibling property

  1. @override
XmlElement? get previousElementSibling
inherited

Return the previous element sibling of this node, or null.

Implementation

@override
XmlElement? get previousElementSibling {
  if (parent != null) {
    final siblings = parent!.children;
    for (var i = siblings.length - 1; i > 0; i--) {
      if (identical(siblings[i], this)) {
        for (var j = i - 1; j >= 0; j--) {
          final candidate = siblings[j];
          if (candidate is XmlElement) {
            return candidate;
          }
        }
        return null;
      }
    }
  }
  return null;
}