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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user