Skip to main content

Wrap

Struct Wrap 

Source
pub struct Wrap {
    pub key: Option<KeyRef>,
    pub direction: Axis,
    pub alignment: WrapAlignment,
    pub spacing: f64,
    pub run_alignment: WrapAlignment,
    pub run_spacing: f64,
    pub cross_axis_alignment: WrapCrossAlignment,
    pub text_direction: Option<TextDirection>,
    pub vertical_direction: VerticalDirection,
    pub clip_behavior: Clip,
    pub children: Vec<WidgetRef>,
}
Expand description

A widget that displays its children in multiple horizontal or vertical runs.

A Wrap lays out each child and attempts to place the child adjacent to the previous child in the main axis, given by direction, leaving spacing space in between. If there is not enough space to fit the child, Wrap creates a new run adjacent to the existing children in the cross axis.

After all the children have been allocated to runs, the children within the runs are positioned according to the alignment in the main axis and according to the cross_axis_alignment in the cross axis.

The runs themselves are then positioned in the cross axis according to the run_spacing and run_alignment.

See also:

Fields§

§key: Option<KeyRef>§direction: Axis

The direction to use as the main axis.

For example, if direction is Axis::Horizontal, the default, the children are placed adjacent to one another in a horizontal run until the available horizontal space is consumed, at which point a subsequent children are placed in a new run vertically adjacent to the previous run.

§alignment: WrapAlignment

How the children within a run should be placed in the main axis.

For example, if alignment is WrapAlignment::Center, the children in each run are grouped together in the center of their run in the main axis.

Defaults to WrapAlignment::Start.

See also:

  • run_alignment, which controls how the runs are placed relative to each other in the cross axis.
  • cross_axis_alignment, which controls how the children within each run are placed relative to each other in the cross axis.
§spacing: f64

How much space to place between children in a run in the main axis.

For example, if spacing is 10.0, the children will be spaced at least 10.0 logical pixels apart in the main axis.

If there is additional free space in a run (e.g., because the wrap has a minimum size that is not filled or because some runs are longer than others), the additional free space will be allocated according to the alignment.

Defaults to 0.0.

§run_alignment: WrapAlignment

How the runs themselves should be placed in the cross axis.

For example, if run_alignment is WrapAlignment::Center, the runs are grouped together in the center of the overall Wrap in the cross axis.

Defaults to WrapAlignment::Start.

See also:

  • alignment, which controls how the children within each run are placed relative to each other in the main axis.
  • cross_axis_alignment, which controls how the children within each run are placed relative to each other in the cross axis.
§run_spacing: f64

How much space to place between the runs themselves in the cross axis.

For example, if run_spacing is 10.0, the runs will be spaced at least 10.0 logical pixels apart in the cross axis.

If there is additional free space in the overall Wrap (e.g., because the wrap has a minimum size that is not filled), the additional free space will be allocated according to the run_alignment.

Defaults to 0.0.

§cross_axis_alignment: WrapCrossAlignment

How the children within a run should be aligned relative to each other in the cross axis.

For example, if this is set to WrapCrossAlignment::End, and the direction is Axis::Horizontal, then the children within each run will have their bottom edges aligned to the bottom edge of the run.

Defaults to WrapCrossAlignment::Start.

See also:

  • alignment, which controls how the children within each run are placed relative to each other in the main axis.
  • run_alignment, which controls how the runs are placed relative to each other in the cross axis.
§text_direction: Option<TextDirection>

Determines the order to lay children out horizontally and how to interpret start and end in the horizontal direction.

Defaults to the ambient Directionality.

If the direction is Axis::Horizontal, this controls order in which the children are positioned (left-to-right or right-to-left), and the meaning of the alignment property’s WrapAlignment::Start and WrapAlignment::End values.

If the direction is Axis::Horizontal, and either the alignment is either WrapAlignment::Start or WrapAlignment::End, or there’s more than one child, then the text_direction (or the ambient Directionality) must not be None.

If the direction is Axis::Vertical, this controls the order in which runs are positioned, the meaning of the run_alignment property’s WrapAlignment::Start and WrapAlignment::End values, as well as the cross_axis_alignment property’s WrapCrossAlignment::Start and WrapCrossAlignment::End values.

If the direction is Axis::Vertical, and either the run_alignment is either WrapAlignment::Start or WrapAlignment::End, the cross_axis_alignment is either WrapCrossAlignment::Start or WrapCrossAlignment::End, or there’s more than one child, then the text_direction (or the ambient Directionality) must not be None.

§vertical_direction: VerticalDirection

Determines the order to lay children out vertically and how to interpret start and end in the vertical direction.

If the direction is Axis::Vertical, this controls which order children are painted in (down or up), the meaning of the alignment property’s WrapAlignment::Start and WrapAlignment::End values.

If the direction is Axis::Horizontal, this controls the order in which runs are positioned, the meaning of the run_alignment property’s WrapAlignment::Start and WrapAlignment::End values, as well as the cross_axis_alignment property’s WrapCrossAlignment::Start and WrapCrossAlignment::End values.

§clip_behavior: Clip

The content will be clipped (or not) according to this option.

Defaults to Clip::None.

§children: Vec<WidgetRef>

Implementations§

Source§

impl Wrap

Source

pub fn new() -> Wrap

Creates a wrap layout; Dart’s named arguments are the setters.

By default, the wrap layout is horizontal and both the children and the runs are aligned to the start.

The text_direction defaults to the ambient Directionality, if any. If there is no ambient directionality, and a text direction is going to be necessary to decide which direction to lay the children in or to disambiguate start or end values for the main or cross axis directions, the text_direction must not be None.

Source

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

Dart Wrap(key:).

Source

pub fn direction(self, direction: Axis) -> Wrap

Dart Wrap(direction:).

Source

pub fn alignment(self, alignment: WrapAlignment) -> Wrap

Dart Wrap(alignment:).

Source

pub fn spacing(self, spacing: f64) -> Wrap

Dart Wrap(spacing:).

Source

pub fn run_alignment(self, run_alignment: WrapAlignment) -> Wrap

Dart Wrap(runAlignment:).

Source

pub fn run_spacing(self, run_spacing: f64) -> Wrap

Dart Wrap(runSpacing:).

Source

pub fn cross_axis_alignment( self, cross_axis_alignment: WrapCrossAlignment, ) -> Wrap

Dart Wrap(crossAxisAlignment:).

Source

pub fn text_direction(self, text_direction: TextDirection) -> Wrap

Dart Wrap(textDirection:).

Source

pub fn vertical_direction(self, vertical_direction: VerticalDirection) -> Wrap

Dart Wrap(verticalDirection:).

Source

pub fn clip_behavior(self, clip_behavior: Clip) -> Wrap

Dart Wrap(clipBehavior:).

Source

pub fn children(self, children: impl IntoIterator<Item = WidgetRef>) -> Wrap

Dart Wrap(children:).

Trait Implementations§

Source§

impl Debug for Wrap

Source§

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

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

impl Default for Wrap

Source§

fn default() -> Wrap

Returns the “default value” for a type. Read more
Source§

impl MultiChildRenderObjectWidget for Wrap

Source§

fn children(&self) -> &[WidgetRef]

The widgets below this widget in the tree. Read more
Source§

fn create_element(&self, app: &mut App, this: WidgetRef) -> AnyElement
where Self: Sized,

Creates the element that manages this widget’s children. Read more
Source§

impl RenderObjectWidget for Wrap

Source§

type RenderObject = RenderWrap

The render object this widget creates; Dart’s covariant RenderObject parameter type.
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 create_render_object( &self, app: &mut App, context: BuildContext, ) -> AnyRenderObject

Creates an instance of the RenderObject class that this widget represents, using the configuration described by this widget. Read more
Source§

fn update_render_object( &self, app: &mut App, context: BuildContext, render_object: RenderHandle<RenderWrap>, )

Copies the configuration described by this widget to the given render object, which will be of the same type as returned by this object’s create_render_object. Read more
Source§

fn to_string_short(&self) -> String

Dart’s toStringShort, for a widget that names itself apart from its type, as SizedBox.expand does; see Widget::to_string_short.
Source§

fn debug_check_constructor(&self)

Source§

fn debug_visit_onstage_children( &self, app: &App, children: &[AnyElement], visitor: &mut dyn FnMut(AnyElement), )

Dart’s 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>, )

A render object previously associated with this widget has been removed from the tree. The given RenderObject will be of the same type as returned by this object’s create_render_object.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Wrap

§

impl !Send for Wrap

§

impl !Sync for Wrap

§

impl !UnwindSafe for Wrap

§

impl Forget for Wrap

§

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

§

impl Move for Wrap

§

impl Unpin for Wrap
where Rc<dyn Key>: Unpin, *const u8 is !null: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for Wrap
where *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> 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<MultiChildRenderObjectKind> 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>