precache method Null safety

bool precache()

Attempts to evaluate the finder. Returns whether any elements in the tree matched the finder. If any did, then the result is cached and can be obtained from evaluate.

If this returns true, you must call evaluate before you call precache again.


bool precache() {
  assert(_cachedResult == null);
  final Iterable<Element> result = apply(allCandidates);
  if (result.isNotEmpty) {
    _cachedResult = result;
    return true;
  _cachedResult = null;
  return false;