{"record":{"id":"b4398e7bb3f5c0e1","repo":"dotnet/maui","slug":"page-b4398e","errorCode":null,"errorMessage":"page","messagePattern":"page","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs","lineNumber":571,"sourceCode":"\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\n\t\tvoid OnPopToRootRequested(object sender, NavigationRequestedEventArgs e)\n\t\t{","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/Renderers/NavigationRenderer.cs#L553-L589","documentation":"In the same InsertPageBefore method, 'page' (the page to insert) must be non-null because it is passed to CreateViewControllerForPage(page) (line 573) which builds its UIViewController. A null page cannot be turned into a controller.","triggerScenarios":"Calling Navigation.InsertPageBefore(null, before) - the page to insert was not constructed or was nulled out.","commonSituations":"Passing a factory result that returned null; binding-driven navigation where the bound page is null; conditional page creation that did not assign.","solutions":["Construct the page instance before calling InsertPageBefore and ensure it is non-null.","Validate the page against null in view-model/navigation-service code.","Use a null-coalescing factory so a default page is always produced."],"exampleFix":"// before\nNavigation.InsertPageBefore(CreatePageOrDefault(), before);\n\n// after\nvar page = CreatePageOrDefault();\nif (page != null)\n    Navigation.InsertPageBefore(page, before);","handlingStrategy":"validation","validationCode":"var page = CreatePage();\nif (page == null) throw new ArgumentNullException(nameof(page));\nNavigation.InsertPageBefore(page, before);","typeGuard":"static bool IsPage(object o) => o is Page;","tryCatchPattern":null,"preventionTips":["Construct and validate the page instance before navigation calls.","Use non-null factories for page creation."],"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"}