title: Flutter: How to set a Observer entire app
body: <p>So, I'm trying to create a chat app and trying to get the user presence but after reading tons of articles on web I still don't get it how I can make it work.. So I'm trying another approach, how can I make a Observer that checks the entire app?</p>
  
  <p>For example right now I have one that I use to tell Firebase Firestore when I'm chatting with someone (setting ID so Cloud Functions don't notify about new message) and I want to use it to tell Firestore when user is online/offline. Is it possible? Thank you.</p>
  
  <p>I tried to create a BaseScreen stateful <code>with WidgetsBindingObserver</code> but don't work.</p>
  
  <pre><code>@override
    void dispose() {
      WidgetsBinding.instance.removeObserver(this);
      super.dispose();
    }
  
    @override
    void didChangeAppLifecycleState(AppLifecycleState state) {
      switch (state) {
        case AppLifecycleState.inactive:
        case AppLifecycleState.paused:
        case AppLifecycleState.suspending:
          //offline or whatever
          break;
        case AppLifecycleState.resumed:
          //active
          break;
      }
    }
  
  </code></pre>