lifecycleObserver top-level property
Implementation
final lifecycleObserver = StreamProvider<AppLifecycleState>((ref) async* {
final observer = AppLifecycleStateObserver(
(state) {
ref.state = AsyncData(state);
},
);
final binding = WidgetsBinding.instance..addObserver(observer);
ref.onDispose(() => binding.removeObserver(observer));
});