Open
Description
Like rootMargin in IntersectionObserver, it would be nice to support setting a detection margin around the VisibilityDetector widget.
For example, this feature enables to prepare required resources (e.g. image fetching, decoding, API request, ...) to show the widget's content before the widget is visible. This may improve the user's experience by fetching the required resources early.
VisibilityDetector(
key: Key('my-widget-key'),
margin: const EdgeInsets.symmetric(vertical: -100.0), // this means to expand the detection area 100px vertically
onVisibilityChanged: (visibilityInfo) {
if (visibilityInfo.visibleFraction > 0) {
prepareForShowingWidget();
}
},
child: someLazyWidget,
)