{"record":{"id":"455db29a08d067fb","repo":"dotnet/maui","slug":"pushasync-is-not-supported-globally-on-gtk-please","errorCode":null,"errorMessage":"PushAsync is not supported globally on GTK, please use a NavigationPage.","messagePattern":"PushAsync is not supported globally on GTK, please use a NavigationPage\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/GTK/Platform.cs","lineNumber":228,"sourceCode":"\n\t\tTask INavigation.PopToRootAsync()\n\t\t{\n\t\t\treturn ((INavigation)this).PopToRootAsync(true);\n\t\t}\n\n\t\tTask INavigation.PopToRootAsync(bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PopToRootAsync is not supported globally on GTK, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask INavigation.PushAsync(Page root)\n\t\t{\n\t\t\treturn ((INavigation)this).PushAsync(root, true);\n\t\t}\n\n\t\tTask INavigation.PushAsync(Page root, bool animated)\n\t\t{\n\t\t\tthrow new InvalidOperationException(\"PushAsync is not supported globally on GTK, please use a NavigationPage.\");\n\t\t}\n\n\t\tTask INavigation.PushModalAsync(Page modal)\n\t\t{\n\t\t\treturn ((INavigation)this).PushModalAsync(modal, true);\n\t\t}\n\n\t\tTask INavigation.PushModalAsync(Page modal, bool animated)\n\t\t{\n\t\t\t_modals.Add(modal);\n\n\t\t\tmodal.DescendantRemoved += HandleChildRemoved;\n\n\t\t\tvar modalRenderer = GetRenderer(modal);\n\t\t\tif (modalRenderer == null)\n\t\t\t{\n\t\t\t\tmodalRenderer = CreateRenderer(modal);\n\t\t\t\tSetRenderer(modal, modalRenderer);","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/GTK/Platform.cs#L210-L246","documentation":"The GTK global Platform does not maintain a non-modal page stack; only modals are tracked. PushAsync would have nowhere to push a page, so it throws InvalidOperationException. Non-modal pushes must go through a NavigationPage whose renderer owns the stack. This mirrors PopToRootAsync and the other global-stack ops on the same class.","triggerScenarios":"Calling await Navigation.PushAsync(page) where Navigation resolves to the global GTK Platform — i.e. the calling Page's parent is the Application/Platform root rather than a NavigationPage. Common when MainPage is a ContentPage directly.","commonSituations":"Shared code that calls Navigation.PushAsync unconditionally across all platforms. App structured with a single root ContentPage on GTK. Migrating from iOS/Android where global push works.","solutions":["Set MainPage to a NavigationPage and navigate through it: Application.Current.MainPage = new NavigationPage(rootPage); then await page.Navigation.PushAsync(next).","If the intent is modal presentation, use await Navigation.PushModalAsync(page) instead — the global Platform supports modals.","Gate platform-specific navigation: if the runtime is GTK, push modally or ensure a NavigationPage is in the hierarchy before pushing."],"exampleFix":"// before\nApplication.Current.MainPage = new ContentPage();\nawait rootPage.Navigation.PushAsync(detailPage); // throws on GTK\n\n// after\nApplication.Current.MainPage = new NavigationPage(new ContentPage());\nawait rootPage.Navigation.PushAsync(detailPage);","handlingStrategy":"validation","validationCode":"if (Application.Current.MainPage is NavigationPage)\n    await page.Navigation.PushAsync(next);\nelse\n    await page.Navigation.PushModalAsync(next); // safe on GTK global Platform","typeGuard":"static bool HasNavStack() => Application.Current?.MainPage is NavigationPage;","tryCatchPattern":null,"preventionTips":["Decide per-platform whether to use a NavigationPage or modals.","Never assume the global Platform supports PushAsync on GTK/macOS.","Route navigation through a thin wrapper that checks the host type."],"tags":["gtk","navigation","navigationpage","platform-limitation","maui","xamarin"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}