Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception when enabling widget-selection mode in Widget Inspector when popover is open #64

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

moescs
Copy link
Contributor

@moescs moescs commented Feb 28, 2023

Visual Studio Code's Widget Inspector causes 'PopoverItem' to throw an exception when trying to recalculate the bounds of the injected 'BuildContext', because the context has been unmounted possibly due to the popover being open and the currently active route. For whatever reason, the widget is mounted when 'didChangeDependencies' is called, but not in the post-frame callback that tries to use the deactivated context.

This pull request prevents the exception from being thrown when enabling widget selection mode in VSCode's Widget Inspector while the popover is open.

This is the issue that is fixed.

Here is a video of the exception before and after it's fixed.
https://user-images.githubusercontent.com/3419440/221905336-380560e0-774c-4274-84e7-4ad131d02995.mp4

I will note that I cannot replicate the issue on the example app included with this library.

when popover is open.

Visual Studio Code's Widget Inspector causes PopoverItem to throw an
exception when trying to recalculate the bounds of the injected BuildContext,
because the context has been unmounted possibly due to the popover being open
and the currently active route. For whatever reason, the widget is mounted
when didChangeDependencies is called, but not in the post-frame callback
that tries to use the deactivated context.
@minikin minikin self-requested a review February 28, 2023 20:41
@codecov
Copy link

codecov bot commented Feb 28, 2023

Codecov Report

Merging #64 (2a2f322) into main (7199969) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #64      +/-   ##
==========================================
+ Coverage   91.98%   92.00%   +0.01%     
==========================================
  Files          10       10              
  Lines         449      450       +1     
==========================================
+ Hits          413      414       +1     
  Misses         36       36              
Impacted Files Coverage Δ
lib/src/popover_item.dart 86.15% <100.00%> (+0.21%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Owner

@minikin minikin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the swift fix!
We'll release a new version tomorrow.

@minikin minikin merged commit a38f34a into minikin:main Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PopoverItem._configureRect() throws trying to access unmounted context when popover is open
2 participants