{"record":{"id":"243b6ae4643d2dd3","repo":"dotnet/maui","slug":"before-243b6a","errorCode":null,"errorMessage":"before","messagePattern":"before","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs","lineNumber":569,"sourceCode":"\t\t}\n\n\t\t[PortHandler]\n\t\tvoid UpdateUseLargeTitles()\n\t\t{\n\t\t\tif (Forms.IsiOS11OrNewer && NavPage != null)\n\t\t\t\tNavigationBar.PrefersLargeTitles = NavPage.OnThisPlatform().PrefersLargeTitles();\n\t\t}\n\n\t\t[PortHandler]\n\t\tvoid UpdateTranslucent()\n\t\t{\n\t\t\tNavigationBar.Translucent = NavPage.OnThisPlatform().IsNavigationBarTranslucent();\n\t\t}\n\n\t\tvoid InsertPageBefore(Page page, Page before)\n\t\t{\n\t\t\tif (before == null)\n\t\t\t\tthrow new ArgumentNullException(\"before\");\n\t\t\tif (page == null)\n\t\t\t\tthrow new ArgumentNullException(\"page\");\n\n\t\t\tvar pageContainer = CreateViewControllerForPage(page);\n\t\t\tvar target = Platform.GetRenderer(before).ViewController.ParentViewController;\n\t\t\tViewControllers = ViewControllers.Insert(ViewControllers.IndexOf(target), pageContainer);\n\t\t}\n\n\t\tvoid OnInsertPageBeforeRequested(object sender, NavigationRequestedEventArgs e)\n\t\t{\n\t\t\tInsertPageBefore(e.Page, e.BeforePage);\n\t\t}\n\n\t\tvoid OnPopRequested(object sender, NavigationRequestedEventArgs e)\n\t\t{\n\t\t\te.Task = PopViewAsync(e.Page, e.Animated);\n\t\t}\n","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs#L551-L587","documentation":"InsertPageBefore(page, before) inserts a page before an existing 'before' page. It immediately calls Platform.GetRenderer(before).ViewController (line 575), so 'before' must be non-null and must already have a renderer; the null guard rejects a null 'before' early.","triggerScenarios":"Calling Navigation.InsertPageBefore(page, null) - e.g. the 'before' page reference was not resolved, or a page lookup returned null because the page is not currently on the stack.","commonSituations":"Inserting before a page that has been popped/removed; passing the wrong page reference; calling InsertPageBefore before the target page is rendered.","solutions":["Ensure 'before' is a page currently on the NavigationPage stack and has been pushed/rendered.","Use NavigationPage.GetPath / inspect Navigation.NavigationStack to confirm the target page exists.","Null-check 'before' before calling InsertPageBefore."],"exampleFix":"// before\nNavigation.InsertPageBefore(newPage, maybeNullPage);\n\n// after\nif (Navigation.NavigationStack.Contains(maybeNullPage))\n    Navigation.InsertPageBefore(newPage, maybeNullPage);","handlingStrategy":"validation","validationCode":"if (before == null) throw new ArgumentNullException(nameof(before));\nif (!Navigation.NavigationStack.Contains(before)) return;\nNavigation.InsertPageBefore(page, before);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm 'before' is on the stack before inserting.","Avoid passing stale page references."],"tags":["argumentnullexception","ios","navigation","insertpagebefore"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}