Positioned class
A widget that controls where a child of a Stack is positioned.
一个用来控制它的子控件在Stack中的放置位置。
A Positioned widget must be a descendant of a Stack, and the path from the Positioned widget to its enclosing Stack must contain only StatelessWidgets or StatefulWidgets (not other kinds of widgets, likeRenderObjectWidgets).
一个
Positiond
控件必须是Stack
的子控件,在Positiond
控件与装入它的Stack
之间,必须只包含StatelessWidget
或者StatefulWidget
。(不能是别的类型,比如RenderObjectWidget)。
If a widget is wrapped in a Positioned, then it is a positioned widget in its Stack. If the top property is non-null, the top edge of this child will be positioned top layout units from the top of the stack widget. The right, bottom, and left properties work analogously.
如果一个控件被
Positioned
包裹,那么它在Stack
中就是一个已经定位的控件。如果top属性不为空,则这个widget
的顶部将与Stack
的顶部间隔与top
值相等单位的距离。右侧,底部和左侧属性的工作方式类似。
If both the top and bottom properties are non-null, then the child will be forced to have exactly the height required to satisfy both constraints. Similarly, setting the right and left properties to non-null values will force the child to have a particular width. Alternatively the width and height properties can be used to give the dimensions, with one corresponding position property (e.g. top and height).
如果
top
和bottom
属性都不为空,则控件将被赋予满足这两项约束的高度。相同的,设置left
和right
属性,将为控件赋予满足约束的宽度。或者给出宽度或者高度属性,加上一个相应的位置属性,来声明控件尺寸(比如,top
和height
)。
If all three values on a particular axis are null, then the Stack.alignment property is used to position the child.
如果三个特定轴上的值都为空,则
Stack.alignment
属性将用来为子控件排序。
If all six values are null, the child is a non-positioned child. The Stack uses only the non-positioned children to size itself.
如果所有六个值都为空,则子控件是一个未定位的控件。
Stack
将会让未定位控件适应它的大小。
See also:
-
PositionedDirectional, which adapts to the ambient Directionality.
-
Inheritance
Object> Diagnosticable> DiagnosticableTree> Widget> ProxyWidget> ParentDataWidget<Stack> >Positioned