title: Detect when user is not interacting the app in Flutter
body: <p>I want to show some Screensaver type of screen when the user is not interacting the app for 5 minutes. So is anyone know how to achieve this kind of functionality in flutter. </p>
  
  <pre><code>import 'dart:async';
  
  import 'package:flutter/material.dart';
  
  const timeout = const Duration(seconds: 10);
  const ms = const Duration(milliseconds: 1);
  Timer timer;
  
  void main() =&gt;
      runApp(MyApp());
  
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      var home = MyHomePage(title: 'Flutter Demo Home Page');
      return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: home,
      );
    }
  
  
  }
  
  class MyHomePage extends StatefulWidget {
    MyHomePage({Key key, this.title}) : super(key: key);
    final String title;
  
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    int _counter = 0;
  
    void _goToSecondScreen() {
      Navigator.pushReplacement(
        context,
        MaterialPageRoute(builder: (context) =&gt; SecondPage()),
      );
    }
  
    @override
    Widget build(BuildContext context) {
      return GestureDetector(child: Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Container(),
        floatingActionButton: FloatingActionButton(
          onPressed: _goToSecondScreen,
          tooltip: 'Increment',
          child: Icon(Icons.add),
        ),
      ), behavior:
      HitTestBehavior.translucent, onTapDown: (tapdown) {
        print("down");
        if (timer != null) {
          timer.cancel();
        }
        timer = startTimeout();
      },);
    }
  
    startTimeout([int milliseconds]) {
      var duration = milliseconds == null ? timeout : ms * milliseconds;
      return new Timer(duration, handleTimeout);
    }
  
    void handleTimeout() {
      Navigator.push(
        context,
        MaterialPageRoute(builder: (context) =&gt; ScreenSaver()),
      );
    }
  
  }
  
  class SecondPage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return new Container();
    }
  }
  class ScreenSaver extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return new GestureDetector(child:Container(color: Colors.yellow,),
        onTap: (){
          Navigator.pop(context);
        },
      );
    }
  }
  </code></pre>
  
  <p>This is the sample code which I am trying to achieve the functionality. When the screen in active in Second screen its not working and the <code>GestureDetector</code> stops listening.</p>