LateBox

用来实现更复杂的响应式布局。用它可以做出市面上常见的那种响应式布局demo(窄/宽/超宽)

LateBox {
    if(width > height) {
        //...
    } else {
        //...
    }
    
    if(width > 300.scaled) {
        //...
    }
}

内部有一个Rect作为接收者。可以读取widthheight等属性来控制内部执行流。

实现

通过把build延迟到LateBoxlayoutVertical阶段执行。此时已经知道了LateBox自身的宽高。

代价是LateBox内部的元素设置Modifier.minSize()并不能撑起LateBox自身的大小,因为它们被添加前LateBox已经完成布局。


This site uses Just the Docs, a documentation theme for Jekyll.