debugIsVisible method Null safety

bool debugIsVisible(
  1. OverlayEntry entry
)

(DEBUG ONLY) Check whether a given entry is visible (i.e., not behind an opaque entry).

This is an O(N) algorithm, and should not be necessary except for debug asserts. To avoid people depending on it, this function is implemented only in debug mode, and always returns false in release mode.

Implementation

bool debugIsVisible(OverlayEntry entry) {
  bool result = false;
  assert(_entries.contains(entry));
  assert(() {
    for (int i = _entries.length - 1; i > 0; i -= 1) {
      final OverlayEntry candidate = _entries[i];
      if (candidate == entry) {
        result = true;
        break;
      }
      if (candidate.opaque) {
        break;
      }
    }
    return true;
  }());
  return result;
}