dotnet/maui · error · InvalidOperationException
Flyout must be set before using a FlyoutPage
Error message
Flyout must be set before using a FlyoutPage
What it means
The IFlyoutPageController.FlyoutBounds setter throws InvalidOperationException when the renderer reports flyout layout bounds but Flyout was never assigned. Symmetric with DetailBounds: platform renderers push the measured flyout rect during layout, and a null Flyout means setup is incomplete.
Source
Thrown at src/Controls/src/Core/FlyoutPage/FlyoutPage.cs:177
Rect IFlyoutPageController.DetailBounds
{
get { return _detailBounds; }
set
{
_detailBounds = value;
if (_detail == null)
throw new InvalidOperationException("Detail must be set before using a FlyoutPage");
}
}
Rect IFlyoutPageController.FlyoutBounds
{
get { return _flyoutBounds; }
set
{
_flyoutBounds = value;
if (_flyout == null)
throw new InvalidOperationException("Flyout must be set before using a FlyoutPage");
}
}
bool IFlyoutPageController.ShouldShowSplitMode
{
get
{
if (DeviceInfo.Idiom == DeviceIdiom.Phone)
return false;
FlyoutLayoutBehavior behavior = FlyoutLayoutBehavior;
var orientation = Window.GetOrientation();
bool isSplitOnLandscape = (behavior == FlyoutLayoutBehavior.SplitOnLandscape || behavior == FlyoutLayoutBehavior.Default) && orientation.IsLandscape();
bool isSplitOnPortrait = behavior == FlyoutLayoutBehavior.SplitOnPortrait && orientation.IsPortrait();
return behavior == FlyoutLayoutBehavior.Split || isSplitOnLandscape || isSplitOnPortrait;
}
}View on GitHub (pinned to f377ff1c5e)
Solutions
- Set Flyout (with a non-empty Title) and Detail before the page enters the visual tree.
- In custom renderers, defer FlyoutBounds assignment until Flyout is non-null.
- Use a factory/builder that validates both children are present.
Example fix
// before
MainPage = new FlyoutPage { Detail = detail };
// renderer sets FlyoutBounds -> throws
// after
MainPage = new FlyoutPage { Flyout = new ContentPage{Title="Menu"}, Detail = detail }; Defensive patterns
Strategy: validation
Validate before calling
if (flyoutPage.Flyout is null) throw new InvalidOperationException("Set Flyout before layout"); Type guard
static bool IsFlyoutPageReady(FlyoutPage p) => p.Flyout is not null && p.Detail is not null;
Prevention
- Set both Flyout (with Title) and Detail before navigating to the page.
- Defer FlyoutBounds assignment in custom renderers until Flyout is non-null.
- Validate setup in a builder before pushing the page.
When it happens
Trigger: A FlyoutPage is laid out by the platform before its Flyout property is set, or a custom renderer assigns FlyoutBounds while Flyout is null.
Common situations: Setting Detail but forgetting Flyout, or a renderer that measures the master pane before the flyout page exists.
Related errors
- Detail must be set before using a FlyoutPage
- IsHeadless cannot be modified when the view is rendered
- Detail cannot be set to null once a value is set.
- Detail must not already have a parent.
- Flyout cannot be set to null once a value is set
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/6072573beb2b8cd1.
Report an issue: GitHub.