onIntersection method
A stream which fires when element intersects with the scroll viewport.
NOTE: This requires IntersectionObserver. Check supportsIntersectionObserver from feature_detector.dart before using.
Implementation
@override
Stream<IntersectionObserverEntry> onIntersection(Element element) {
assert(feature_detector.supportsIntersectionObserver);
_intersectionStreams[element] ??=
StreamController<IntersectionObserverEntry>.broadcast(
onListen: () => _intersectionObserver!.observe(element),
onCancel: () => _intersectionObserver!.unobserve(element),
sync: true);
return _intersectionStreams[element]!.stream;
}