visibility_detector
0.4.0+2, released 4 years ago by google.dev
Widget that reports visibility changes of its child
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.
- scroll_spy
Detect visible items and select one stable primary item in Flutter scrollables.
67Compare - keyboard_detection
Detect keyboard visibility using bottom view inset in Flutter
56Compare - flutter_swipe_detector
A Flutter widget to detect swipe directions and provide callbacks for gestures.
50Compare - keyboard_visibility_pro
Detects soft-keyboard open and close status in Flutter applications.
39Compare
Works with
Packages commonly used together with visibility_detector: ones it builds on, ones built on it, and its own family.
- wechat_assets_pickerBuilt on visibility_detectorAn asset picker widget for images, videos, and audio based on WeChat's UI.
- extended_nested_scroll_viewBuilt on visibility_detectorExtended nested scroll view to fix pinned header and inner scrollables sync issues.
- html_editor_enhancedBuilt on visibility_detectorHTML rich text editor for Android, iOS, and Web using the Summernote library
- focus_detectorBuilt on visibility_detectorDetects when your widget appears or disappears from the screen.
- flutter_uxcamBuilt on visibility_detectorFlutter wrapper plugin for UXCam SDK to connect and configure app analytics and screen recordings.
- auto_animatedBuilt on visibility_detectorWidgets that automatically play entrance animations when mounted or scrolled into view.
- focus_on_itBuilt on visibility_detectorGet notified when a Flutter widget is focused or unfocused and react to it.
- markdown_widgetBuilt on visibility_detectorA simple and easy-to-use markdown rendering component for Flutter.