From ea52878a3e8fb96ab202e345ff6a1a18b47b2d9b Mon Sep 17 00:00:00 2001 From: Adam Drzewiecki Date: Tue, 19 Dec 2023 20:16:35 +0100 Subject: [PATCH] Fix "VirtualView cannot be null here" --- .../Platforms/Android/Handler/PopupPageRenderer.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Mopups/Mopups.Maui/Platforms/Android/Handler/PopupPageRenderer.cs b/Mopups/Mopups.Maui/Platforms/Android/Handler/PopupPageRenderer.cs index b6d8a79..9ddca9b 100644 --- a/Mopups/Mopups.Maui/Platforms/Android/Handler/PopupPageRenderer.cs +++ b/Mopups/Mopups.Maui/Platforms/Android/Handler/PopupPageRenderer.cs @@ -115,13 +115,13 @@ protected override void OnLayout(bool changed, int left, int top, int right, int systemPadding = new Thickness(); } - (PopupHandler.VirtualView as PopupPage).SetValue(PopupPage.SystemPaddingProperty, systemPadding); - (PopupHandler.VirtualView as PopupPage).SetValue(PopupPage.KeyboardOffsetProperty, keyboardOffset); + (PopupHandler.VirtualView as PopupPage)?.SetValue(PopupPage.SystemPaddingProperty, systemPadding); + (PopupHandler.VirtualView as PopupPage)?.SetValue(PopupPage.KeyboardOffsetProperty, keyboardOffset); if (changed) - (PopupHandler.VirtualView as PopupPage).Layout(new Rect(Context.FromPixels(left), Context.FromPixels(top), Context.FromPixels(right), Context.FromPixels(bottom))); + (PopupHandler.VirtualView as PopupPage)?.Layout(new Rect(Context.FromPixels(left), Context.FromPixels(top), Context.FromPixels(right), Context.FromPixels(bottom))); else - (PopupHandler.VirtualView as PopupPage).ForceLayout(); + (PopupHandler.VirtualView as PopupPage)?.ForceLayout(); base.OnLayout(changed, left, top, right, bottom); //base.OnLayout(changed, 20, 500, 1080, 2000); //base.OnLayout(changed, visibleRect.Left, visibleRect.Top, visibleRect.Right, visibleRect.Bottom);