focus_detector 1.0.1 focus_detector: ^1.0.1 copied to clipboard
Android's onResume/onPause and iOS's viewDidAppear/viewDidDisappear for Flutter.
FocusDetector #
Wrapper around Google's VisibilityDetector for combining it with Flutter's WidgetsBindingObserver in order to achieve Android's onResume/onPause and iOS's viewDidAppear/viewDidDisappear on Flutter.
How Does it Work? #
A FocusDetector widget takes in a child and optional onFocusGained
/onFocusLost
callbacks and fires those as the widget's focus changes.
Some cases that trigger the focus change:
- When the widget is first created;
- When its route is popped back to;
- When the app is sent to background/foreground while the widget was visible;
Article #
Sample #
Check out the set-state-focus-detector
or bloc-focus-detector
branch of the Breaking Bapp repository.