Repository: flutter
Issue: Unexpected route is popped 
Labels: framework,f: routes,has reproducible steps,P2,found in release: 3.10,found in release: 3.11,team-framework,triaged-framework

Hi,

I am having a navigation issue where if some route is doing an API call and that route can be popped on success of notification but if some other route is pushed onto the route (Maybe due to notification navigation) then after the API process is done the topmost route (The route which has pushed on notification) is popped rather than previous route (The route where API has been processed)

## Steps to Reproduce

Push two route (B, C) from the same page (A) & write some future to modulate API call in widget B & pop it in the future. You will see C is getting popped rather than B.

Updated Sample.zip with lib & pubspec file

**Expected results:**  In android B gets popped behind the scene without interfering with C & after C is popped by user it goes directly to A.

**Actual results:** C is getting popped instead of B and B stays in the stack.

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```
[+1006 ms] I/flutter (32338): initState first page
[+4159 ms] I/ViewRootImpl(32338): ViewRoot's Touch Event : ACTION_DOWN
[  +80 ms] I/ViewRootImpl(32338): ViewRoot's Touch Event : ACTION_UP
[ +474 ms] I/AudioManagerEx(32338): AudioManagerEx created
[+2176 ms] I/flutter (32338): initState second page
[ +952 ms] I/flutter (32338): initState third page
[+2312 ms] I/flutter (32338): function complete
[  +32 ms] I/flutter (32338): dismissing route 3
[ +426 ms] I/flutter (32338): dispose third page
[+1961 ms] I/ViewRootImpl(32338): ViewRoot's KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0,
eventTime=10311148, downTime=10311148, deviceId=-1, source=0x101 } to DecorView@72ed49b[MainActivity]
[  +80 ms] I/ViewRootImpl(32338): ViewRoot's KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0,
eventTime=10311230, downTime=10311148, deviceId=-1, source=0x101 } to DecorView@72ed49b[MainActivity]
[ +113 ms] I/flutter (32338): null
[ +299 ms] I/flutter (32338): dispose second page
[+3130 ms] I/ViewRootImpl(32338): ViewRoot's KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0,
eventTime=10314774, downTime=10314774, deviceId=-1, source=0x101 } to DecorView@72ed49b[MainActivity]
[ +114 ms] I/ViewRootImpl(32338): ViewRoot's KeyEvent { action=ACTION_UP, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0,
eventTime=10314889, downTime=10314774, deviceId=-1, source=0x101 } to DecorView@72ed49b[MainActivity]
[ +465 ms] W/InputMethodManager(32338): APP_CALLED_RESTART_INPUT_API  failed. Window focus may have already been lost. win=null
view=io.flutter.embedding.android.FlutterView{e9ccb02 VFE...... .F......
0,0-1080,2004},focus=true,windowFocus=false,window=android.view.ViewRootImpl$WEx@4293c13,temporaryDetach=false
[   +1 ms] W/InputMethodManager(32338): force mHasBeenInactive = true
[  +36 ms] E/libEGL  (32338): call to OpenGL ES API with no current context (logged once per thread)
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
No issues found! (ran in 3.5s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->
```
[✓] Flutter (Channel stable, 2.0.5, on Linux, locale en_IN)
    • Flutter version 2.0.5 at /home/faiyyaz/snap/flutter/common/flutter
    • Framework revision adc687823a (3 weeks ago), 2021-04-16 09:40:20 -0700
    • Engine revision b09f014e96
    • Dart version 2.12.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /home/faiyyaz/Android/Sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /usr/bin/java
    • Java version Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[✓] IntelliJ IDEA Community Edition (version 2020.3)
    • IntelliJ at /home/faiyyaz/Personal/idea-IC-203.7717.56
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.56.0)
    • VS Code at /usr/share/code
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (2 available)
    • LG M700 (mobile) • LGM70035d57187 • android-arm    • Android 8.1.0 (API 27)
    • Chrome (web)     • chrome         • web-javascript • Google Chrome 90.0.4430.93

! Doctor found issues in 1 category.
```

</details>

[sample.zip](https://github.com/flutter/flutter/files/6443572/sample.zip)