Skip to main content

Positioned

Struct Positioned 

Source
pub struct Positioned {
    pub key: Option<KeyRef>,
    pub left: Option<f64>,
    pub top: Option<f64>,
    pub right: Option<f64>,
    pub bottom: Option<f64>,
    pub width: Option<f64>,
    pub height: Option<f64>,
    pub child: WidgetRef,
}
Expand description

A widget that controls where a child of a Stack is positioned.

A Positioned widget must be a descendant of a Stack, and the path from the Positioned widget to its enclosing Stack must contain only stateless or stateful widgets (not other kinds of widgets, like render object widgets).

If a widget is wrapped in a Positioned, then it is a positioned widget in its Stack. If the top property is non-None, 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.

If both the top and bottom properties are non-None, 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-None 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).

If all three values on a particular axis are None, then the Stack::alignment property is used to position the child.

If all six values are None, the child is a non-positioned child. The Stack uses only the non-positioned children to size itself.

Only two out of the three horizontal values (left, right, width), and only two out of the three vertical values (top, bottom, height), can be set. In each case, at least one of the three must be None.

Fields§

§key: Option<KeyRef>§left: Option<f64>

The distance that the child’s left edge is inset from the left of the stack.

Only two out of the three horizontal values (left, right, width) can be set. The third must be None.

If all three are None, the Stack::alignment is used to position the child horizontally.

§top: Option<f64>

The distance that the child’s top edge is inset from the top of the stack.

Only two out of the three vertical values (top, bottom, height) can be set. The third must be None.

If all three are None, the Stack::alignment is used to position the child vertically.

§right: Option<f64>

The distance that the child’s right edge is inset from the right of the stack.

See left.

§bottom: Option<f64>

The distance that the child’s bottom edge is inset from the bottom of the stack.

See top.

§width: Option<f64>

The child’s width.

See left.

§height: Option<f64>

The child’s height.

See top.

§child: WidgetRef

Implementations§

Source§

impl Positioned

Source

pub fn new<K>(child: impl IntoWidget<K>) -> Positioned

Creates a widget that controls where a child of a Stack is positioned; Dart’s optional named arguments are the setters.

Source

pub fn from_rect<K>(rect: Rect, child: impl IntoWidget<K>) -> Positioned

Creates a Positioned object with the values from the given Rect.

This sets the left, top, width, and height properties from the given Rect. The right and bottom properties are set to None.

Source

pub fn from_relative_rect<K>( rect: RelativeRect, child: impl IntoWidget<K>, ) -> Positioned

Creates a Positioned object with the values from the given RelativeRect.

This sets the left, top, right, and bottom properties from the given RelativeRect. The height and width properties are set to None.

Source

pub fn fill<K>(child: impl IntoWidget<K>) -> Positioned

Creates a Positioned object with left, top, right, and bottom set to 0.0 unless a value for them is passed.

Source

pub fn directional<K>( text_direction: TextDirection, start: Option<f64>, end: Option<f64>, child: impl IntoWidget<K>, ) -> Positioned

Creates a widget that controls where a child of a Stack is positioned, taking start and end rather than left and right.

If text_direction is TextDirection::Rtl, then the start argument is used for the right property and the end argument is used for the left property. Otherwise, if text_direction is TextDirection::Ltr, then the start argument is used for the left property and the end argument is used for the right property.

Dart Positioned.directional(textDirection:, start:, end:, child:); start and end are arguments rather than setters because resolving them needs the text direction.

Source

pub fn key(self, key: KeyRef) -> Positioned

Dart Positioned(key:).

Source

pub fn left(self, left: f64) -> Positioned

Dart Positioned(left:).

Source

pub fn top(self, top: f64) -> Positioned

Dart Positioned(top:).

Source

pub fn right(self, right: f64) -> Positioned

Dart Positioned(right:).

Source

pub fn bottom(self, bottom: f64) -> Positioned

Dart Positioned(bottom:).

Source

pub fn width(self, width: f64) -> Positioned

Dart Positioned(width:).

Source

pub fn height(self, height: f64) -> Positioned

Dart Positioned(height:).

Trait Implementations§

Source§

impl Debug for Positioned

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ParentDataWidget for Positioned

Source§

type ParentData = StackParentData

The parent data this widget writes; Dart’s T extends ParentData.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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 child(&self) -> &WidgetRef

The widget below this widget in the tree.
Source§

fn debug_is_valid_render_object( &self, app: &App, render_object: AnyRenderObject, ) -> bool

Dart’s debugIsValidRenderObject: whether render_object’s parent data is the one this widget writes. Read more
Source§

fn apply_parent_data(&self, app: &mut App, render_object: AnyRenderObject)

Write the data from this widget into the given render object’s parent data. Read more
Source§

fn debug_check_constructor(&self)

Source§

fn debug_can_apply_out_of_turn(&self) -> bool

Whether the ParentDataElement::apply_widget_out_of_turn method will be allowed with this widget. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Positioned

§

impl !Send for Positioned

§

impl !Sync for Positioned

§

impl !UnwindSafe for Positioned

§

impl Forget for Positioned

§

impl Freeze for Positioned
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl Move for Positioned

§

impl Unpin for Positioned
where Rc<dyn Key>: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for Positioned
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> IntoWidget<ParentDataKind> for W

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>