title: didChangeAppLifecycleState is not working Flutter
body: <p>I have the app of more than 20 screens , I want to perform a task if user is inactive/idle for a certain time.
  I am trying to get the app's lifecycle at root of app. But i am not getting print statements on my logcat. What wrong I have done here?</p>
  <pre><code>void main() async{
    WidgetsFlutterBinding.ensureInitialized();
   
    runApp(MyApp());
  }
  
  class MyApp extends StatefulWidget {
   
  
    @override
    State&lt;StatefulWidget&gt; createState() =&gt; _MyAppState();
  }
  
  class _MyAppState extends State&lt;MyApp&gt; with WidgetsBindingObserver{
  
  
    @override
    didChangeAppLifecycleState(AppLifecycleState state) {
      switch (state) {
        case AppLifecycleState.resumed:
          print('app resumed');
          break;
        case AppLifecycleState.inactive:
          print('app inactive');
          break;
        case AppLifecycleState.paused:
          print('app paused');
          break;
        case AppLifecycleState.detached:
          print('app detached');
          break;
      }
    }
     @override
    void initState() {
      WidgetsBinding.instance.addObserver(this);
      super.initState();
      _initializeTimer();
    }
    @override
    void dispose() {
      WidgetsBinding.instance.removeObserver(this);
      super.dispose();
    }
    }
  </code></pre>