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:
Row, which places children in one line, and gives control over their alignment and spacing.- The catalog of layout widgets.
Fields§
§key: Option<KeyRef>§direction: AxisThe 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: WrapAlignmentHow 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: f64How 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: WrapAlignmentHow 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: f64How 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: WrapCrossAlignmentHow 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: VerticalDirectionDetermines 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: ClipThe content will be clipped (or not) according to this option.
Defaults to Clip::None.
children: Vec<WidgetRef>Implementations§
Source§impl Wrap
impl Wrap
Sourcepub fn new() -> Wrap
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.
Sourcepub fn alignment(self, alignment: WrapAlignment) -> Wrap
pub fn alignment(self, alignment: WrapAlignment) -> Wrap
Dart Wrap(alignment:).
Sourcepub fn run_alignment(self, run_alignment: WrapAlignment) -> Wrap
pub fn run_alignment(self, run_alignment: WrapAlignment) -> Wrap
Dart Wrap(runAlignment:).
Sourcepub fn run_spacing(self, run_spacing: f64) -> Wrap
pub fn run_spacing(self, run_spacing: f64) -> Wrap
Dart Wrap(runSpacing:).
Sourcepub fn cross_axis_alignment(
self,
cross_axis_alignment: WrapCrossAlignment,
) -> Wrap
pub fn cross_axis_alignment( self, cross_axis_alignment: WrapCrossAlignment, ) -> Wrap
Dart Wrap(crossAxisAlignment:).
Sourcepub fn text_direction(self, text_direction: TextDirection) -> Wrap
pub fn text_direction(self, text_direction: TextDirection) -> Wrap
Dart Wrap(textDirection:).
Sourcepub fn vertical_direction(self, vertical_direction: VerticalDirection) -> Wrap
pub fn vertical_direction(self, vertical_direction: VerticalDirection) -> Wrap
Dart Wrap(verticalDirection:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> Wrap
pub fn clip_behavior(self, clip_behavior: Clip) -> Wrap
Dart Wrap(clipBehavior:).
Sourcepub fn children(self, children: impl IntoIterator<Item = WidgetRef>) -> Wrap
pub fn children(self, children: impl IntoIterator<Item = WidgetRef>) -> Wrap
Dart Wrap(children:).
Trait Implementations§
Source§impl MultiChildRenderObjectWidget for Wrap
impl MultiChildRenderObjectWidget for Wrap
Source§impl RenderObjectWidget for Wrap
impl RenderObjectWidget for Wrap
Source§type RenderObject = RenderWrap
type RenderObject = RenderWrap
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<RenderWrap>,
)
fn update_render_object( &self, app: &mut App, context: BuildContext, render_object: RenderHandle<RenderWrap>, )
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 Wrap
impl !Send for Wrap
impl !Sync for Wrap
impl !UnwindSafe for Wrap
impl Forget for Wrap
impl Freeze for Wrap
impl Move for Wrap
impl Unpin for Wrap
impl UnsafeUnpin for Wrapwhere
*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.