Skip to content
pubscout

visibility_detector

0.4.0+2, released 4 years ago by google.dev

Widget that reports visibility changes of its child

WASM-readyRepository archivedQuiet but busy
$ flutter pub add visibility_detector
Source repository

What it does

Wraps a child widget and notifies a callback when its visibility changes. The callback receives a VisibilityInfo with the visible fraction.

AI-written summary of version 0.4.0+2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Track analytics or ad impressions
  • Trigger lazy loading or animations when a widget becomes visible
  • Detect when a widget is scrolled off screen

Skip it when

  • When visibility must account for opacity or overlapping widgets
  • When precise pixel-level visibility is required

Strengths

  • Simple API, no extra dependencies
  • Cross-platform support (android, ios, web, desktop)
  • Coalesced callbacks reduce overhead

Weaknesses

  • Does not consider widget opacity
  • Visible fraction may be inaccurate if obscured by other widgets

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
VisibilityDetector(
  key: Key('my-widget-key'),
  onVisibilityChanged: (visibilityInfo) {
    var visiblePercentage = visibilityInfo.visibleFraction * 100;
    debugPrint(
        'Widget ${visibilityInfo.key} is ${visiblePercentage}% visible');
  },
  child: someOtherWidget,
);

Alternatives

Packages that do the same job and could replace visibility_detector.

Works with

Packages commonly used together with visibility_detector: ones it builds on, ones built on it, and its own family.