title: When typing the mobile back button, the flutter application exits
body: <p>I have a problem, when typing in the mobile back button, my application exists. However when i click in the back button icon, in my  AppBar Screen, i navigate to the previous screen, whitch is good.</p>
  <p>I would like to know why the mobile back button do not navigate to the previous screen like the AppBar back button icon ?</p>
  <p>I have done my test by using this code from <a href="https://medium.com/flutterdevs/flutter-migrate-to-navigator-2-0-851f568ac0a3" rel="nofollow noreferrer">https://medium.com/flutterdevs/flutter-migrate-to-navigator-2-0-851f568ac0a3</a>:</p>
  <p>import 'package:flutter/material.dart';</p>
  <pre><code>void main() {
    runApp(MyApp());
  }
  
  class MyApp extends StatefulWidget {
    // This widget is the root of your application.
    @override
    _MyAppState createState() =&gt; _MyAppState();
  }
  
  class _MyAppState extends State&lt;MyApp&gt; {
    bool isStacked = false;
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: Navigator(
          pages: [
            MaterialPage(
              key: ValueKey('unique '),
              child: Screen1(
                onTap: (value) {
                  isStacked = value;
                  setState(() {});
                },
              ),
            ),
            if (isStacked == true)
              MaterialPage(
                child: Screen2(),
              ),
          ],
          onPopPage: (route, result) {
            if (!route.didPop(result)) return false;
            setState(() =&gt; isStacked = false);
            return true;
          },
        ),
      );
    }
  }
  
  class Screen1 extends StatelessWidget {
    Function(bool) onTap;
  
    Screen1({this.onTap});
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(&quot;Navigator 2.0&quot;),
        ),
        body: Center(
          child: InkWell(
            onTap: () {
              onTap(true);
            },
            child: Text(
              'Screen 1 \n tap on text to maove to screen2',
            ),
          ),
        ),
      );
    }
  }
  
  class Screen2 extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(&quot;Back to Screen 1&quot;),
        ),
        body: Center(
          child: InkWell(
            child: Text(
              'Screen 2 ',
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  <p>I wrap the Navigator widget in WillPopScope widget, but the mobile back button do not work.</p>
  <p>Thanks.</p>