如何知道 RenderBox 的 Positioned 属性?

How to know the Positioned properties from a RenderBox?

我有一个堆栈,其中包含一个已定位的 children。 我需要将一个 child 移动到另一个,我可以通过

获得另一个 child 的偏移量
RenderBox box = key.currentContext.findRenderObject();
Offset position = box.localToGlobal(Offset.zero); 

但我无法准确获取要设置动画的顶部和开始属性

AnimatedPositionedDirectional(
            duration: Duration(milliseconds: 700),  
            top: ??,
            start: ??

您实际上可以使用 top 和 left 属性 通过偏移设置小部件的位置。

顶部定义要从顶部移动多少,左侧定义要从左侧移动多少。

您可以通过以下方式分配偏移量变量dx和dy。

top: position.dy
left: position.dx