dotnet/maui · error · ArgumentNullException
Detail cannot be set to null once a value is set.
Error message
Detail cannot be set to null once a value is set.
What it means
FlyoutPage.Detail setter throws ArgumentNullException when an existing Detail is being replaced by null. Once a Detail is assigned, the page's layout, handlers, and child collection assume a non-null detail; clearing it would leave the layout in an inconsistent state, so the API forbids it.
Source
Thrown at src/Controls/src/Core/FlyoutPage/FlyoutPage.cs:47
Page _detail;
Rect _detailBounds;
Page _flyout;
Rect _flyoutBounds;
IFlyoutPageController FlyoutPageController => this;
/// <summary>Gets or sets the detail page that is used to display details about items on the flyout page.</summary>
public Page Detail
{
get { return _detail; }
set
{
if (_detail != null && value == null)
throw new ArgumentNullException(nameof(value), "Detail cannot be set to null once a value is set.");
if (_detail == value)
return;
if (value.RealParent != null)
throw new InvalidOperationException("Detail must not already have a parent.");
var previousDetail = _detail;
previousDetail?.SendNavigatingFrom(new NavigatingFromEventArgs(destinationPage: value, navigationType: NavigationType.Replace));
// Update the detail property
OnPropertyChanging();
if (_detail is not null)
InternalChildren.Remove(_detail);
_detail = value;
InternalChildren.Add(_detail);
OnPropertyChanged();View on GitHub (pinned to f377ff1c5e)
Solutions
- Replace the Detail with a new empty/placeholder Page instead of null: `flyoutPage.Detail = new ContentPage();`.
- If you need to clear the whole FlyoutPage, remove the FlyoutPage from navigation rather than nulling Detail.
- Bind Detail to a non-nullable Page property that always yields a valid page.
- Guard any cleanup code against assigning null once Detail is set.
Example fix
// before
flyoutPage.Detail = null;
// after
flyoutPage.Detail = new ContentPage { Title = "Empty" }; Defensive patterns
Strategy: validation
Validate before calling
if (flyoutPage.Detail != null && newDetail is null) flyoutPage.Detail = new ContentPage(); else flyoutPage.Detail = newDetail;
Try / catch
try { flyoutPage.Detail = value; } catch (ArgumentNullException) { flyoutPage.Detail = new ContentPage(); } Prevention
- Never null out Detail after it is set; substitute an empty ContentPage.
- Bind Detail to a non-nullable Page view-model property.
- Clear the FlyoutPage from navigation rather than nulling its children.
When it happens
Trigger: Assigning `flyoutPage.Detail = null;` after a non-null Detail was previously set. Common in navigation reset logic or when tearing down a screen.
Common situations: Logout/cleanup flows that null out child pages, reactive view models that bind Detail to a nullable property, or replacing a detail by first nulling then re-assigning.
Related errors
- Flyout cannot be set to null once a value is set
- Detail must not already have a parent.
- Title property must be set on Flyout page
- Flyout must not already have a parent.
- PopToRootAsync is not supported globally on GTK, please use
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/afaaf5e6ed3015ea.
Report an issue: GitHub.