How to know if a widget is visible within a viewport?

https://pub.dev/packages/visibility_detector provides this functionality with its VisibilityDetector widget that can wrap any other Widget and notify when the visible area of the widget changed:

VisibilityDetector(
   key: Key("unique key"),
   onVisibilityChanged: (VisibilityInfo info) {
       debugPrint("${info.visibleFraction} of my widget is visible");
   },
   child: MyWidgetToTrack());
)

Leave a Comment