previousElementSibling property Null safety

Element? previousElementSibling

Implementation

Element? get previousElementSibling {
  if (parentNode == null) return null;
  final siblings = parentNode!.nodes;
  for (var i = siblings.indexOf(this) - 1; i >= 0; i--) {
    final s = siblings[i];
    if (s is Element) return s;
  }
  return null;
}