focus_detector_v2
위젯이 화면에 나타나거나 화면에서 사라질 때를 감지합니다.
Android의 onResume/onPause 및 iOS의 viewDidAppear/viewDidDisappear용 Flutter.
{"sdk":"flutter"}^0.4.0+2{"sdk":"flutter"}^2.0.1아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Focus Detector Logo
Pub.dev Badge GitHub Build Badge Gitter Badge Effective Dart Badge MIT License Badge Flutter Platform Badge
Get notified every time your widget appears or disappears from the screen.
Similar to onResume()/onPause() on Android and viewDidAppear()/viewDidDisappear() on iOS.
Focus Detector fires callbacks for you whenever something happens to take or give your widget focus. Such an event might be, for instance, the user:
@override
Widget build(BuildContext context) =>
FocusDetector(
onFocusLost: () {
logger.i(
'Focus Lost.'
'\nTriggered when either [onVisibilityLost] or [onForegroundLost] '
'is called.'
'\nEquivalent to onPause() on Android or viewDidDisappear() on iOS.',
);
},
onFocusGained: () {
logger.i(
'Focus Gained.'
'\nTriggered when either [onVisibilityGained] or [onForegroundGained] '
'is called.'
'\nEquivalent to onResume() on Android or viewDidAppear() on iOS.',
);
},
onVisibilityLost: () {
logger.i(
'Visibility Lost.'
'\nIt means the widget is no longer visible within your app.',
);
},
onVisibilityGained: () {
logger.i(
'Visibility Gained.'
'\nIt means the widget is now visible within your app.',
);
},
onForegroundLost: () {
logger.i(
'Foreground Lost.'
'\nIt means, for example, that the user sent your app to the background by opening '
'another app or turned off the device\'s screen while your '
'widget was visible.',
);
},
onForegroundGained: () {
logger.i(
'Foreground Gained.'
'\nIt means, for example, that the user switched back to your app or turned the '
'device\'s screen back on while your widget was visible.',
);
},
isWidgetTest: false,
child: Container(),
);
This is a forked version of Focus Detector. It was not updated for more than a year, so I made the V2 for my personal projects. To migrate from the V1, update the pubspec.yml dependency from focus_detector: ^2.0.1 to focus_detector_v2: ^3.1.0 and adjust your import inside dart files.
Contributions of any kind are welcome. Feel free to improve the library by creating a pull request or opening an issue.