lifecycleObserver top-level property

StreamProvider<AppLifecycleState> lifecycleObserver
final

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));
});