FIX: More like a workaround for issue https://github.com/woltapp/wolt… #375
+132
−22
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.
FIX: #374
Summary of my and AI analysis of the Problem
!debugNeedsLayout
fails withinRenderFractionalTranslation.hitTestChildren
.RenderFractionalTranslation
object while that object has been marked as needing a layout update (markNeedsLayout
was called) but before the layout update has actually been performed (performLayout
hasn't run yet in the current frame pipeline for this object). This is not allowed because hit testing requires up-to-date layout information (size and position) to work correctly.ListView
) inside the modal sheet.ListView
).ScrollNotification
that bubbles up from theListView
.WoltModalSheet
widget listens for these notifications to potentially react to the scroll position (e.g., maybe for subtle animations, overscroll effects, or coordinating with sheet dragging).setState
to update some state related to the sheet's position or appearance.setState
triggers a rebuild. During the build, widgets related to the sheet's positioning (which often involveSlideTransition
or other animations internally usingFractionalTranslation
->RenderFractionalTranslation
) get updated. This marks their correspondingRenderObject
s (likeRenderFractionalTranslation
) as needing layout (markNeedsLayout()
).RenderFractionalTranslation
, the assertion!debugNeedsLayout
fails because layout hasn't happened yet for it in this frame.Workaround fix
To avoid this issue I for now made a workaround I can use temporarily at least. However, a real fix should involve getting rid of any out-of bounds set state calls in relation the used scroll listeners.
The temp fix is a bit of hack, every usage of the Flutter
SlideTransition
(which under the hood is aFractionalTranslation
) was replaced with a simple custom pixel‑basedTransform.translate
widget calledPixelSlideTransition
. That completely removes the underlyingFractionalTranslation
hit‑test logic that was tripping the“!debugNeedsLayout”
assertion when we spin the mouse wheel.I also wrapped our route’s entrance/exit transition in an
AbsorbPointer
so that no pointer events (incl. wheel scrolls) ever hit the sheet until its first layout is fully finished. Alsothrottled our TopBarFlow’s scroll listener to only call setState in the next frame (so we never mark the sheet dirty mid‑hitTest).
All of these changes combined eliminate the debugMode crash we are seeing.
I am going to submit the changes as a PR so you can take a look at them. I don't think it is necessary a good actual actual fix to merge, but I must get rid of the assert now. And will use a temporary fork with this fix in it to do so while waiting for a better actual fix.
You may use the PR as inspiration if you like, but as said I'm not expecting it to be merged, you can of course if you so like, but I think finding and fixing the actual cause would be better.
A proper fix should probably prefer getting rid of all out-of bounds
setState
calls in relation the used scroll listeners.I tried the fix with the demo issue and also with the package bundled
playground
example. Worked for both cases.