pub struct Stack {
pub key: Option<KeyRef>,
pub alignment: AlignmentGeometry,
pub text_direction: Option<TextDirection>,
pub fit: StackFit,
pub clip_behavior: Clip,
pub children: Vec<WidgetRef>,
}Expand description
A widget that positions its children relative to the edges of its box.
This class is useful if you want to overlap several children in a simple way, for example having some text and an image, overlaid with a gradient and a button attached to the bottom.
Each child of a Stack widget is either positioned or non-positioned.
Positioned children are those wrapped in a Positioned widget that has at
least one non-None property. The stack sizes itself to contain all the
non-positioned children, which are positioned according to
alignment (which defaults to the top-left corner in
left-to-right environments and the top-right corner in right-to-left
environments). The positioned children are then placed relative to the stack
according to their top, right, bottom, and left properties.
The stack paints its children in order with the first child being at the
bottom. If you want to change the order in which the children paint, you
can rebuild the stack with the children in the new order. If you reorder
the children in this way, consider giving the children non-None keys.
These keys will cause the framework to move the underlying objects for
the children to their new locations rather than recreate them at their
new location.
For more details about the stack layout algorithm, see RenderStack.
See also:
Align, which sizes itself based on its child’s size and positions the child according to anAlignmentvalue.- The catalog of layout widgets.
Fields§
§key: Option<KeyRef>§alignment: AlignmentGeometryHow to align the non-positioned and partially-positioned children in the stack.
The non-positioned children are placed relative to each other such that the points
determined by alignment are co-located. For example, if the
alignment is AlignmentGeometry::TOP_LEFT, then the top left corner of each
non-positioned child will be located at the same global coordinate.
Partially-positioned children, those that do not specify an alignment in a particular
axis (e.g. that have neither top nor bottom set), use the alignment to determine how
they should be positioned in that under-specified axis.
Defaults to AlignmentGeometry::TOP_START.
text_direction: Option<TextDirection>The text direction with which to resolve alignment.
Defaults to the ambient Directionality.
fit: StackFitHow to size the non-positioned children in the stack.
The constraints passed into the Stack from its parent are either loosened
(StackFit::Loose) or tightened to their biggest size (StackFit::Expand).
clip_behavior: ClipStacks only clip children whose geometry overflows the stack. A child that paints outside its bounds (e.g. a box with a shadow) will not be clipped, regardless of the value of this property. Similarly, a child that itself has a descendant that overflows the stack will not be clipped, as only the geometry of the stack’s direct children are considered.
Even when this is set to Clip::None, the stack itself does not extend its hit-test
region: pointer events that fall outside the stack’s own bounds will not reach a child
even if that child is painted in that area.
Defaults to Clip::HardEdge.
children: Vec<WidgetRef>Implementations§
Source§impl Stack
impl Stack
Sourcepub fn new() -> Stack
pub fn new() -> Stack
Creates a Stack; Dart’s named arguments are the setters.
By default, the non-positioned children of the stack are aligned by their top left corners.
Sourcepub fn alignment(self, alignment: AlignmentGeometry) -> Stack
pub fn alignment(self, alignment: AlignmentGeometry) -> Stack
Dart Stack(alignment:).
Sourcepub fn text_direction(self, text_direction: TextDirection) -> Stack
pub fn text_direction(self, text_direction: TextDirection) -> Stack
Dart Stack(textDirection:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> Stack
pub fn clip_behavior(self, clip_behavior: Clip) -> Stack
Dart Stack(clipBehavior:).
Sourcepub fn children(self, children: impl IntoIterator<Item = WidgetRef>) -> Stack
pub fn children(self, children: impl IntoIterator<Item = WidgetRef>) -> Stack
Dart Stack(children:).
Trait Implementations§
Source§impl MultiChildRenderObjectWidget for Stack
impl MultiChildRenderObjectWidget for Stack
Source§impl RenderObjectWidget for Stack
impl RenderObjectWidget for Stack
Source§type RenderObject = RenderStack
type RenderObject = RenderStack
covariant RenderObject parameter type.Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn create_render_object(
&self,
app: &mut App,
context: BuildContext,
) -> AnyRenderObject
fn create_render_object( &self, app: &mut App, context: BuildContext, ) -> AnyRenderObject
RenderObject class that this widget represents, using the
configuration described by this widget. Read moreSource§fn update_render_object(
&self,
app: &mut App,
context: BuildContext,
render_object: RenderHandle<RenderStack>,
)
fn update_render_object( &self, app: &mut App, context: BuildContext, render_object: RenderHandle<RenderStack>, )
create_render_object. Read moreSource§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
toStringShort, for a widget that names itself apart from its type, as
SizedBox.expand does; see Widget::to_string_short.Source§fn debug_visit_onstage_children(
&self,
app: &App,
children: &[AnyElement],
visitor: &mut dyn FnMut(AnyElement),
)
fn debug_visit_onstage_children( &self, app: &App, children: &[AnyElement], visitor: &mut dyn FnMut(AnyElement), )
debugVisitOnstageChildren of the element this widget makes, for a widget whose
Dart element subclass overrides it only to hide children (_OffstageElement,
_IndexedStackElement): calls visitor for each of children, in order, that is
onstage. Waft’s generic single- and multi-child elements stand in for those subclasses
and ask their widget here; an element of a widget’s own overrides
Element::debug_visit_onstage_children instead.Source§fn did_unmount_render_object(
&self,
app: &mut App,
render_object: RenderHandle<Self::RenderObject>,
)
fn did_unmount_render_object( &self, app: &mut App, render_object: RenderHandle<Self::RenderObject>, )
RenderObject will be of the same type as returned by this object’s
create_render_object.Auto Trait Implementations§
impl !RefUnwindSafe for Stack
impl !Send for Stack
impl !Sync for Stack
impl !UnwindSafe for Stack
impl Forget for Stack
impl Freeze for Stack
impl Move for Stack
impl Unpin for Stack
impl UnsafeUnpin for Stackwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Rc<dyn Widget>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<MultiChildRenderObjectKind> for Wwhere
W: MultiChildRenderObjectWidget,
<W as RenderObjectWidget>::RenderObject: ContainerRenderObjectMixin,
impl<W> IntoWidget<MultiChildRenderObjectKind> for Wwhere
W: MultiChildRenderObjectWidget,
<W as RenderObjectWidget>::RenderObject: ContainerRenderObjectMixin,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.