Skip to content

iOS: Navigator.of(context) inside a nested Navigator returns the app's stack while a sheet is up #107

Backlog

Description

@tayormi

Select your plan

Standard - priority support

Confirmations

  • I searched the existing issues and this is not a duplicate.

Framework or plugin?

Framework

Plugin name and version

No response

Platform

iOS

Public reproduction repo

https://github.com/tayormi/dn-issue-repros

Steps to reproduce

Navigator.of(context), with a context inside a Navigator widget, returns the app's own stack while a sheet is presented. A push made from the sheet's callback with the page's context then lands on the app's stack, over the tab bar, instead of in the tab. The Navigator.of docs describe this ("While a presentation is up or a screen of the app's own stack covers the nearest Navigator widget, the app's own stack"), so it's a documented divergence from Flutter, but it makes a common pattern land in the wrong place with no error.

Setup, all in lib/repros/08_navigator_of_with_sheet.dart: the screen's body is a Navigator widget, with a grey strip under it standing in for the tab bar. Every button calls Navigator.of(pageContext).push(...) with the context of the first page inside that Navigator. The pushed page says which navigator the call returned, and is green in the nested Navigator, red on the app's stack.

  1. Clone the reproduction repo linked above and run dn run on an iOS simulator (seen on the iPhone Air, iOS 26.5 simulator).
  2. Tap 08 Navigator.of while a sheet is up.
  3. Control: tap Push (no sheet) (works). The page lands in the nested Navigator, above the grey tab bar. Tap Back.
  4. Tap Open sheet, then Push from the sheet (bug). The sheet's button pushes with the page's context, then closes the sheet.
  5. Observe: the page lands on the app's own stack. It covers the tab bar and reads "Navigator.of(pageContext) = the app's own stack".
  6. Control: tap Back, Open sheet, then Close, then push (works). The push made once await showModalSheet(...) returns lands in the nested Navigator.

Expected (as in Flutter): Navigator.of(context) is the nearest Navigator above context, whatever is presented, so step 4 pushes in the tab. If the redirect is wanted for Navigator.pop(context) (closing what's on top), it could apply to pop/maybePop only, or there could be an opt-out such as Navigator.of(context, nearest: true).

In a real app this comes from a sheet that picks something and opens its detail page straight from the pick callback. Our workaround pushes by the tab navigator's GlobalKey everywhere instead of Navigator.of.

Screenshots or video

Control: no sheet Bug: pushed from the sheet
No sheet Pushed from the sheet

Logs

No response

dn doctor output

[!] DartNative (Channel stable, 1.10.0, on macOS 26.6 25G72 darwin-arm64, locale en-CA) [499ms]
    • DartNative version 1.10.0 on channel stable at ~/zero
    ! Warning: `flutter` on your path resolves to ~/Flutter/flutter/bin/flutter, which is not inside your current DartNative SDK checkout at ~/zero. Consider adding ~/zero/bin to the front of your path.
    ! Warning: `dart` on your path resolves to ~/Flutter/flutter/bin/dart, which is not inside your current DartNative SDK checkout at ~/zero. Consider adding ~/zero/bin to the front of your path.
    • Downloaded from https://cdn.dartnative.com; "dn upgrade" moves it to the newest release, "dn releases" lists the others
    • Framework revision bdfb466e6d1 (4 days ago), 2026-11-24 15:36:11 +0100
    • Framework edition b2263be6a0167213
    • Engine revision de099f669f
    • Dart version 3.12.0 (build 3.12.0-192.0.dev)
    • DevTools version 2.55.0
    • DartNative download mirror https://cdn.dartnative.com
    • Feature flags: enable-android, enable-ios, cli-animations, enable-native-assets, enable-lldb-debugging, enable-uiscene-migration
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[!] Xcode - develop for iOS and macOS (Xcode 27.2) [938ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 27B52
    ! iOS 27.2 Simulator not installed; this may be necessary for iOS and macOS development.
      To download and install the platform, open Xcode, select Xcode > Settings > Components,
      and click the GET button for the required platform.

      For more information, please visit:
        https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes
    • CocoaPods version 1.16.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions