ux: Pane.flushLayoutSync — synchronous layout pass for inline measurement

Subclasses that need a child's real measured size at gesture-time (not
the next frame) can set a per-class measure-request field and call this
to make `performLayout` run synchronously, observe the field, and
populate sizes. No extra frame scheduled.

Banlu's chat-stream uses this for scroll-to-reply on far-back history
that hasn't been laid out yet — without it, the path is either iterative
single-viewport jumps (waits for layout per jump) or minHeight estimates
that misalign the landing position.
This commit is contained in:
agra
2026-05-21 14:07:15 +03:00
parent d68a2978eb
commit 05d408a50f

View File

@@ -90,6 +90,19 @@ abstract class Pane with Emitter {
return child;
}
/// Forces a synchronous layout pass on this Pane. Callers that need a
/// slot's real measured size *now* (e.g. scroll-to-message in a chat
/// that hasn't laid out far-back history yet) set up a per-subclass
/// "measure request" field, then invoke this — the next [performLayout]
/// observes the field and measures the requested slots inline. No
/// extra frame is scheduled.
void flushLayoutSync() {
final owner = renderer?.owner;
if (owner == null) return;
renderer!.markNeedsLayout();
owner.flushLayout();
}
void invokeLayoutRemove(Object? slot) {
if (element == null) return;
renderer?.invokeLayoutCallback((constraints) {