Repository navigation
Conversation
`_sendFeedback` awaited `sendFeedback(...)` and then unconditionally called
`BetterFeedback.of(context).hide()` behind an `// ignore:
use_build_context_synchronously`. When the host screen is popped while the
submission is in flight (screenshot upload on a slow connection, back gesture,
app backgrounded and route discarded), the lookup walks a deactivated element
and throws:
Looking up a deactivated widget's ancestor is unsafe
Guard the call with `context.mounted` instead of suppressing the lint.
Submitting feedback and tearing the widget tree down before the send delay elapses used to throw "Looking up a deactivated widget's ancestor is unsafe" from BetterFeedback.of() in FeedbackWidgetState._sendFeedback. The new test drives the real submit flow, replaces the tree with a bare SizedBox while the send is in flight, and asserts that the onFeedback callback still ran and that no exception escaped.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
_sendFeedbackawaitssendFeedback(...)and then unconditionally callsBetterFeedback.of(context).hide(), with the lint suppressed:If the host screen is popped while the submission is still in flight — screenshot upload on a slow connection, back gesture, route discarded while the app is backgrounded — the lookup walks a deactivated element and throws:
Related to #359, which fixed the same class of problem for the focus restore on web.
Fix
Replace the lint suppression with a real guard:
When the context is gone there is nothing left to hide, so returning early is the correct behaviour.
dart formatclean, no API change.