Fixes Rare '<optimized out>' Exception when changing Body Content-Type back to json #780
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.
PR Description
While using the application I came across an issue that is a fairly common user-flow.
When adding Json to Body and switching to text and switching back, we get an exception.
This does not happen for all types of JSON but it has happened to me a couple of times. Especially when using JSON from LLMs.
EXCEPTION_VIDEO.mov
Fixes: #782
I identified the source of this issue to this line:
Adding a 50ms delay fixed this problem and running the same set of steps does not reproduce the error now
After Fix:
FIX_VIDEO.mov
The examples mentioned in the issue are directly copied from the internet/LLMs (which many of our users are going to do).
We cannot expect users to go and manually format their copied json bodies for this to work reliably. Hence I wanted to fix this issue.
My approach has been tested against all these examples and has not reproduced that error again.
Hence, please review & merge this!
Thanks
Checklist
main
branch before making this PRflutter upgrade
and verify)flutter test
) and all tests are passingOS on which you have developed and tested the feature?