{"record":{"id":"890f4accf7eeac47","repo":"dotnet/maui","slug":"flyout-cannot-be-set-to-null-once-a-value-is-set","errorCode":null,"errorMessage":"Flyout cannot be set to null once a value is set","messagePattern":"Flyout cannot be set to null once a value is set","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/FlyoutPage/FlyoutPage.cs","lineNumber":115,"sourceCode":"\t\t\tget { return (bool)GetValue(IsGestureEnabledProperty); }\n\t\t\tset { SetValue(IsGestureEnabledProperty, BooleanBoxes.Box(value)); }\n\t\t}\n\n\t\t/// <summary>Gets or sets a value that indicates whether the flyout is presented. This is a bindable property.</summary>\n\t\tpublic bool IsPresented\n\t\t{\n\t\t\tget { return (bool)GetValue(IsPresentedProperty); }\n\t\t\tset { SetValue(IsPresentedProperty, BooleanBoxes.Box(value)); }\n\t\t}\n\n\t\t/// <summary>Gets or sets the flyout page that is used to present a menu or navigation options.</summary>\n\t\tpublic Page Flyout\n\t\t{\n\t\t\tget { return _flyout; }\n\t\t\tset\n\t\t\t{\n\t\t\t\tif (_flyout != null && value == null)\n\t\t\t\t\tthrow new ArgumentNullException(nameof(value), \"Flyout cannot be set to null once a value is set\");\n\n\t\t\t\tif (string.IsNullOrEmpty(value.Title))\n\t\t\t\t\tthrow new InvalidOperationException(\"Title property must be set on Flyout page\");\n\n\t\t\t\tif (_flyout == value)\n\t\t\t\t\treturn;\n\n\t\t\t\tif (value.RealParent != null)\n\t\t\t\t\tthrow new InvalidOperationException(\"Flyout must not already have a parent.\");\n\n\t\t\t\t// TODO MAUI refine this to fire earlier\n\t\t\t\tvar previousFlyout = _flyout;\n\t\t\t\t\n\t\t\t\t// TODO MAUI refine this to fire earlier\n\t\t\t\tpreviousFlyout?.SendNavigatingFrom(new NavigatingFromEventArgs(value, NavigationType.Replace));\n\n\t\t\t\tOnPropertyChanging();\n\t\t\t\tif (_flyout != null)","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/FlyoutPage/FlyoutPage.cs#L97-L133","documentation":"FlyoutPage.Flyout setter throws ArgumentNullException when an existing Flyout is being replaced by null. The flyout pane is structurally required by every FlyoutPage layout; clearing it would leave the split/drawer layout with no menu surface, so the API forbids null after a value is set.","triggerScenarios":"Assigning `flyoutPage.Flyout = null;` after a non-null Flyout was previously set, e.g. in a teardown or conditional-menu path.","commonSituations":"Logout flows, conditional menus that hide the flyout by nulling it, or view-model bindings that expose a nullable flyout page.","solutions":["Replace the Flyout with a minimal placeholder Page (with a Title) instead of null.","Hide the flyout via IsPresented=false or FlyoutLayoutBehavior rather than nulling the page.","Bind Flyout to a non-nullable Page that always returns a valid (even if empty) menu page."],"exampleFix":"// before\nflyoutPage.Flyout = null;\n\n// after\nflyoutPage.Flyout = new ContentPage { Title = \"Menu\" };\nflyoutPage.IsPresented = false;","handlingStrategy":"validation","validationCode":"if (flyoutPage.Flyout != null && newFlyout is null) flyoutPage.Flyout = new ContentPage{Title=\"Menu\"}; else flyoutPage.Flyout = newFlyout;","typeGuard":null,"tryCatchPattern":"try { flyoutPage.Flyout = value; } catch (ArgumentNullException) { flyoutPage.Flyout = new ContentPage{Title=\"Menu\"}; }","preventionTips":["Replace the flyout with a placeholder page instead of null.","Hide via IsPresented or layout behavior, not by nulling.","Keep the bound Flyout view-model property non-null."],"tags":["maui","flyoutpage","navigation","state"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}