Skip to content

fix: defer drop-position setState to avoid mutation during layout pass#59

Merged
caduandrade merged 1 commit into
caduandrade:mainfrom
Manuelmik:fix/setState-during-layout-pass
Mar 18, 2026
Merged

fix: defer drop-position setState to avoid mutation during layout pass#59
caduandrade merged 1 commit into
caduandrade:mainfrom
Manuelmik:fix/setState-during-layout-pass

Conversation

@Manuelmik
Copy link
Copy Markdown
Contributor

Problem

When dragging a tab over a split-view pane, onWillAcceptWithDetails on the
DragTarget inside ContentWrapperBase's LayoutBuilder fires synchronously
during Flutter's layout phase. The listener callback immediately calls setState(),
which marks a sibling pane's RenderObject as needing layout while the current
LayoutBuilder is still in performLayout. Flutter asserts in debug mode:

A _RenderLayoutBuilder was mutated in _RenderLayoutBuilder.performLayout.

Reproducible with two panes in split view — drag any tab a couple times (fast): sometimes it fires.

Fix

Wrap the setState in SchedulerBinding.instance.addPostFrameCallback in both
DockingItemWidgetState and DockingTabsWidgetState. This defers the state
update until after the current frame's layout and paint are complete.

@caduandrade caduandrade self-assigned this Mar 18, 2026
@caduandrade
Copy link
Copy Markdown
Owner

@Manuelmik

Thank you for fixing that!

@caduandrade caduandrade added the bug Something isn't working label Mar 18, 2026
@caduandrade caduandrade added this to the 1.16.2 milestone Mar 18, 2026
@caduandrade caduandrade merged commit 21f01d1 into caduandrade:main Mar 18, 2026
2 of 3 checks passed
@caduandrade
Copy link
Copy Markdown
Owner

Version 1.16.2 released. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants