FLUTTER ECOSYSTEM

focus_detector

Detects when your widget appears or disappears from the screen.

Latest version
2.0.1
30-day downloads
31K
Likes
361
Pub points
130

Package Overview

Selection guidance generated from public package information. For reference only.

Overview

FocusDetector is a Flutter package that detects when a widget gains or loses focus, allowing developers to respond to visibility changes in real time. It provides callbacks for when a widget appears on screen (focus gained) or disappears (focus lost), making it ideal for animations, tracking user interactions, or managing state based on visibility. The package works across all major platforms including Android, iOS, Web, macOS, Windows, and Linux, ensuring consistent behavior regardless of the target environment. It integrates seamlessly into existing Flutter apps with minimal setup.

Use cases
  • Tracking widget visibility for analytics
  • Triggering animations on appearance
  • Managing state based on focus status
  • Optimizing performance by pausing inactive widgets
  • Implementing responsive UIs that react to focus changes
Key features
  • Real-time focus detection
  • Cross-platform compatibility
  • Simple callback-based API
  • Lightweight and easy to integrate
  • Supports both focus gain and loss events
Suitable for
  • Developers building interactive UIs
  • Apps requiring visibility-aware logic
  • Animations triggered by user focus
  • Performance-sensitive applications
  • Widgets needing lifecycle awareness
Considerations
  • Requires proper widget tree structure
  • May not work as expected with complex nested layouts
  • Not suitable for non-interactive widgets
  • Limited to focus-related events only
  • Best used with stateful widgets or controllers
Supported platformsAndroidiOSWebmacOSWindowsLinux

Install package

flutter pub add focus_detector

Categories

Source repository

Related projects