You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If you enable widget selection mode in VSCode's Widget Inspector while the popover is open, it triggers didChangeDependencies to schedule a _configureRect in PopoverItem. The problem is that the BuildContext becomes unmounted between didChangeDependencies and the post frame callback.
To Reproduce
Steps to reproduce the behavior:
Use VSCode.
Add a popover using showPopover().
Run the app using VSCode's debugger.
Open the Widget Inspector.
Open the popover in the app (trigger a call to showPopover()).
Click the toggle button to turn select widget mode on in the Widget Inspector.
BuildContextExtension.getWidgetLocalToGlobal() in _configureRect() throws the following error:
FlutterError (Cannot get renderObject of inactive element.
In order for an element to have a valid renderObject, it must be active, which means it is part of the tree.
Instead, this element is in the _ElementLifecycle.defunct state.
If you called this method from a State object, consider guarding it with State.mounted.
The findRenderObject() method was called for the following element:
StatelessElement#7e777(DEFUNCT))
Expected behavior
No error should be thrown.
Desktop (please complete the following information):
OS: Windows 11
Desktop app
Version 10.0.22621 Build 22621
Additional comments
A possible solution is to add if (!widget.context.mounted) return; at the top of _configureRect(). I would generate a pull request, but I'm not sure if this would be exempt from testing when reading your guidelines. I can't think of a good way to test it.
The text was updated successfully, but these errors were encountered:
@moescs Thank you for the report. I don't have access to a Windows machine.
Would you mind creating a PR with the fix and recording a short video to showcase that the issue is fixed?
Describe the bug
If you enable widget selection mode in VSCode's Widget Inspector while the popover is open, it triggers
didChangeDependencies
to schedule a_configureRect
inPopoverItem
. The problem is that theBuildContext
becomes unmounted betweendidChangeDependencies
and the post frame callback.To Reproduce
Steps to reproduce the behavior:
Use VSCode.
Add a popover using
showPopover()
.Run the app using VSCode's debugger.
Open the Widget Inspector.
Open the popover in the app (trigger a call to
showPopover()
).Click the toggle button to turn select widget mode on in the Widget Inspector.
BuildContextExtension.getWidgetLocalToGlobal()
in_configureRect()
throws the following error:Expected behavior
No error should be thrown.
Desktop (please complete the following information):
Additional comments
A possible solution is to add
if (!widget.context.mounted) return;
at the top of_configureRect()
. I would generate a pull request, but I'm not sure if this would be exempt from testing when reading your guidelines. I can't think of a good way to test it.The text was updated successfully, but these errors were encountered: