반응형
with WidgetsBindingObserver
믹싱을 통해 해당 클래스를 추가하고 didChangeAppLifecycleState를 사용해서 감지는 잘 되는데 해당 메소드에서 로직이 안돌아간다면 ?
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
case AppLifecycleState.resumed:
debugPrint("========= AppLifecycleState.resumed =========");
ref.read(notificationPermissionProvider.notifier).checkPermission();
break;
case AppLifecycleState.inactive:
break;
case AppLifecycleState.paused:
debugPrint("========= AppLifecycleState.paused =========");
break;
case AppLifecycleState.detached:
debugPrint("========= AppLifecycleState.detached =========");
break;
default:
// Handle any other states that might be added in the future
break;
}
super.didChangeAppLifecycleState(state);
}
initState() 메소드에 옵저버 인스턴스를 등록해주자. dispose로 메모리 해제는 잊지말고.
WidgetsBinding.instance.addObserver(this);
'Flutter' 카테고리의 다른 글
[Dart] 스택(Stack), 힙(Heap), 데이터 영역(Data Segment) 그리고 가비지 컬렉션 (0) | 2024.10.22 |
---|---|
Flutter[플러터] - IOS 스플래쉬 검은화면 제거하기 feat .flutter_native_splash (0) | 2024.07.24 |
[Flutter] - 플러터, ios 알림 권한 Permission.notification.status isDenied (0) | 2024.07.16 |
[Flutter] 플러터 - 네트워크 상태 감지 connectivity_plus (2) | 2024.07.08 |
[Flutter] 플러터 - IOS - Parse Issue (Xcode): Module 'app_links' not found (0) | 2024.06.29 |