title: flutter navigation pop always pop to root
body: <p>I'm new on flutter and I got a problem with navigation pop system. I don't understand what's wrong on my code but what should I check on my code if every time I pressed back button on phone(not on AppBar or anything else), it goes back to the root of my page, not the previous page. but it works perfectly when I press back using the app bar back button that created automatically.</p>
  
  <p>I've tried to fix this issue by passing some unpassed BuildContext to my separated widget hoping that's the problem but still doesn't works</p>
  
  <p>Example:
  I have three pages A, B, C </p>
  
  <p>A->B->C</p>
  
  <p>A->B->D</p>
  
  <p>A->B->E</p>
  
  <p>when I press smartphone's back button on B it goes to A (works).</p>
  
  <p>when I press Scaffold appbar back button on C it goes to B (still works),</p>
  
  <p>But, when I press smartphone's back button on C, D, or E it goes to A (not works)</p>
  
  <pre class="lang-dart prettyprint-override"><code>//this is where I initialize my route
  class _LoginPageState extends State&lt;LoginPage&gt;{
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        routes: &lt;String, WidgetBuilder&gt; {
        '/main': (BuildContext context) =&gt; MainPage(),
        // '/b': (BuildContext context) =&gt; MyPage(title: 'page B'),
        // '/c': (BuildContext context) =&gt; MyPage(title: 'page C'),
      },
  .....
  
  
  // and this is how I push 
  onPressed: () {
    Navigator.of(context).pushNamed('/main');
  }
  </code></pre>