pub trait RenderStackBase: RenderBoxContainerDefaultsMixin<ParentDataType = StackParentData> {
Show 25 methods
// Required methods
fn stack_data(self: RenderHandle<Self>, app: &App) -> &RenderStackData;
fn stack_data_mut(
self: RenderHandle<Self>,
app: &mut App,
) -> &mut RenderStackData;
// Provided methods
fn setup_parent_data(
self: RenderHandle<Self>,
app: &mut App,
child: AnyRenderObject,
) { ... }
fn resolved_alignment(self: RenderHandle<Self>, app: &mut App) -> Alignment { ... }
fn mark_need_resolution(self: RenderHandle<Self>, app: &mut App) { ... }
fn alignment(self: RenderHandle<Self>, app: &App) -> AlignmentGeometry { ... }
fn set_alignment(
self: RenderHandle<Self>,
app: &mut App,
value: AlignmentGeometry,
) { ... }
fn text_direction(
self: RenderHandle<Self>,
app: &App,
) -> Option<TextDirection> { ... }
fn set_text_direction(
self: RenderHandle<Self>,
app: &mut App,
value: Option<TextDirection>,
) { ... }
fn fit(self: RenderHandle<Self>, app: &App) -> StackFit { ... }
fn set_fit(self: RenderHandle<Self>, app: &mut App, value: StackFit) { ... }
fn clip_behavior(self: RenderHandle<Self>, app: &App) -> Clip { ... }
fn set_clip_behavior(self: RenderHandle<Self>, app: &mut App, value: Clip) { ... }
fn compute_min_intrinsic_width(
self: RenderHandle<Self>,
app: &mut App,
height: f64,
) -> f64 { ... }
fn compute_max_intrinsic_width(
self: RenderHandle<Self>,
app: &mut App,
height: f64,
) -> f64 { ... }
fn compute_min_intrinsic_height(
self: RenderHandle<Self>,
app: &mut App,
width: f64,
) -> f64 { ... }
fn compute_max_intrinsic_height(
self: RenderHandle<Self>,
app: &mut App,
width: f64,
) -> f64 { ... }
fn compute_distance_to_actual_baseline(
self: RenderHandle<Self>,
app: &mut App,
baseline: TextBaseline,
) -> Option<f64> { ... }
fn compute_dry_baseline(
self: RenderHandle<Self>,
app: &mut App,
constraints: BoxConstraints,
baseline: TextBaseline,
) -> Option<f64> { ... }
fn compute_dry_layout(
self: RenderHandle<Self>,
app: &mut App,
constraints: BoxConstraints,
) -> Size { ... }
fn compute_size(
self: RenderHandle<Self>,
app: &mut App,
constraints: BoxConstraints,
layout_child: impl FnMut(&mut App, AnyRenderBox, BoxConstraints) -> Size,
) -> Size { ... }
fn perform_layout(self: RenderHandle<Self>, app: &mut App) { ... }
fn paint_stack(
self: RenderHandle<Self>,
app: &mut App,
context: &mut PaintingContext,
offset: Offset,
) { ... }
fn paint(
self: RenderHandle<Self>,
app: &mut App,
context: &mut PaintingContext,
offset: Offset,
) { ... }
fn dispose(self: RenderHandle<Self>, app: &mut App) { ... }
}Expand description
Implements the stack layout algorithm.
In a stack layout, the children are positioned on top of each other in the order in which they appear in the child list. First, the non-positioned children (those with null values for top, right, bottom, and left) are laid out and initially placed in the upper-left corner of the stack. The stack is then sized to enclose all of the non-positioned children. If there are no non-positioned children, the stack becomes as large as possible.
The final location of non-positioned children is determined by the alignment parameter. The
left of each non-positioned child becomes the difference between the stack’s width and the
child’s width multiplied by (alignment.x + 1.0) / 2.0. The top of each non-positioned child is
computed similarly from the stack’s height, the child’s height, and alignment.y.
Next, the positioned children are laid out. If a child has top and bottom values that are both non-null, the child is given a fixed height determined by subtracting the sum of the top and bottom values from the height of the stack. Similarly, if the child has right and left values that are both non-null, the child is given a fixed width derived from the stack’s width. Otherwise, the child is given unbounded constraints in the non-fixed dimensions.
Once the child is laid out, the stack positions the child according to the top, right, bottom,
and left properties of their StackParentData. If the child extends beyond the bounds of the
stack, the stack will clip the child’s painting to the bounds of the stack.
Flutter’s RenderStack bodies. RenderStack is the plain leaf; RenderIndexedStack
implements this trait too and overrides paint_stack.
Required Methods§
Sourcefn stack_data(self: RenderHandle<Self>, app: &App) -> &RenderStackData
fn stack_data(self: RenderHandle<Self>, app: &App) -> &RenderStackData
Mixin field access.
Sourcefn stack_data_mut(
self: RenderHandle<Self>,
app: &mut App,
) -> &mut RenderStackData
fn stack_data_mut( self: RenderHandle<Self>, app: &mut App, ) -> &mut RenderStackData
See stack_data.
Provided Methods§
Sourcefn setup_parent_data(
self: RenderHandle<Self>,
app: &mut App,
child: AnyRenderObject,
)
fn setup_parent_data( self: RenderHandle<Self>, app: &mut App, child: AnyRenderObject, )
Installs StackParentData unless the child already has it.
The body of Flutter’s setupParentData override; call it from
RenderBox::setup_parent_data.
Sourcefn resolved_alignment(self: RenderHandle<Self>, app: &mut App) -> Alignment
fn resolved_alignment(self: RenderHandle<Self>, app: &mut App) -> Alignment
The alignment resolved against
text_direction, cached until either changes.
Sourcefn mark_need_resolution(self: RenderHandle<Self>, app: &mut App)
fn mark_need_resolution(self: RenderHandle<Self>, app: &mut App)
Drops the resolved alignment and marks layout dirty.
Sourcefn alignment(self: RenderHandle<Self>, app: &App) -> AlignmentGeometry
fn alignment(self: RenderHandle<Self>, app: &App) -> AlignmentGeometry
How to align the non-positioned or partially-positioned children in the stack.
The non-positioned children are placed relative to each other such that the points
determined by the 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.
If this is set to a directional alignment, then text_direction
must not be None.
Sourcefn set_alignment(
self: RenderHandle<Self>,
app: &mut App,
value: AlignmentGeometry,
)
fn set_alignment( self: RenderHandle<Self>, app: &mut App, value: AlignmentGeometry, )
Sets alignment.
Sourcefn text_direction(self: RenderHandle<Self>, app: &App) -> Option<TextDirection>
fn text_direction(self: RenderHandle<Self>, app: &App) -> Option<TextDirection>
The text direction with which to resolve alignment.
This may be changed to None, but only after the alignment has been changed to a value
that does not depend on the direction.
Sourcefn set_text_direction(
self: RenderHandle<Self>,
app: &mut App,
value: Option<TextDirection>,
)
fn set_text_direction( self: RenderHandle<Self>, app: &mut App, value: Option<TextDirection>, )
Sets text_direction.
Sourcefn fit(self: RenderHandle<Self>, app: &App) -> StackFit
fn fit(self: RenderHandle<Self>, app: &App) -> StackFit
How 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).
Sourcefn clip_behavior(self: RenderHandle<Self>, app: &App) -> Clip
fn clip_behavior(self: RenderHandle<Self>, app: &App) -> Clip
How to clip the children that overflow the stack.
Stacks 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.
Defaults to Clip::HardEdge.
Sourcefn set_clip_behavior(self: RenderHandle<Self>, app: &mut App, value: Clip)
fn set_clip_behavior(self: RenderHandle<Self>, app: &mut App, value: Clip)
Sets clip_behavior.
Sourcefn compute_min_intrinsic_width(
self: RenderHandle<Self>,
app: &mut App,
height: f64,
) -> f64
fn compute_min_intrinsic_width( self: RenderHandle<Self>, app: &mut App, height: f64, ) -> f64
The stack’s minimum intrinsic width: the widest non-positioned child’s.
Sourcefn compute_max_intrinsic_width(
self: RenderHandle<Self>,
app: &mut App,
height: f64,
) -> f64
fn compute_max_intrinsic_width( self: RenderHandle<Self>, app: &mut App, height: f64, ) -> f64
The stack’s maximum intrinsic width: the widest non-positioned child’s.
Sourcefn compute_min_intrinsic_height(
self: RenderHandle<Self>,
app: &mut App,
width: f64,
) -> f64
fn compute_min_intrinsic_height( self: RenderHandle<Self>, app: &mut App, width: f64, ) -> f64
The stack’s minimum intrinsic height: the tallest non-positioned child’s.
Sourcefn compute_max_intrinsic_height(
self: RenderHandle<Self>,
app: &mut App,
width: f64,
) -> f64
fn compute_max_intrinsic_height( self: RenderHandle<Self>, app: &mut App, width: f64, ) -> f64
The stack’s maximum intrinsic height: the tallest non-positioned child’s.
Sourcefn compute_distance_to_actual_baseline(
self: RenderHandle<Self>,
app: &mut App,
baseline: TextBaseline,
) -> Option<f64>
fn compute_distance_to_actual_baseline( self: RenderHandle<Self>, app: &mut App, baseline: TextBaseline, ) -> Option<f64>
The stack’s baseline: the highest of its children’s.
Sourcefn compute_dry_baseline(
self: RenderHandle<Self>,
app: &mut App,
constraints: BoxConstraints,
baseline: TextBaseline,
) -> Option<f64>
fn compute_dry_baseline( self: RenderHandle<Self>, app: &mut App, constraints: BoxConstraints, baseline: TextBaseline, ) -> Option<f64>
The baseline the stack would have, measuring its children dry.
Sourcefn compute_dry_layout(
self: RenderHandle<Self>,
app: &mut App,
constraints: BoxConstraints,
) -> Size
fn compute_dry_layout( self: RenderHandle<Self>, app: &mut App, constraints: BoxConstraints, ) -> Size
The size the stack would take, measuring its non-positioned children dry.
Sourcefn compute_size(
self: RenderHandle<Self>,
app: &mut App,
constraints: BoxConstraints,
layout_child: impl FnMut(&mut App, AnyRenderBox, BoxConstraints) -> Size,
) -> Size
fn compute_size( self: RenderHandle<Self>, app: &mut App, constraints: BoxConstraints, layout_child: impl FnMut(&mut App, AnyRenderBox, BoxConstraints) -> Size, ) -> Size
Flutter’s _computeSize: measures the non-positioned children with layout_child and
sizes the stack.
Sourcefn perform_layout(self: RenderHandle<Self>, app: &mut App)
fn perform_layout(self: RenderHandle<Self>, app: &mut App)
The body of Flutter’s performLayout override.
Sourcefn paint_stack(
self: RenderHandle<Self>,
app: &mut App,
context: &mut PaintingContext,
offset: Offset,
)
fn paint_stack( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, )
Override in subclasses to customize how the stack paints.
By default, the stack uses default_paint.
This function is called by paint after potentially applying a clip to
contain visual overflow.
Sourcefn paint(
self: RenderHandle<Self>,
app: &mut App,
context: &mut PaintingContext,
offset: Offset,
)
fn paint( self: RenderHandle<Self>, app: &mut App, context: &mut PaintingContext, offset: Offset, )
The body of Flutter’s paint override.
Sourcefn dispose(self: RenderHandle<Self>, app: &mut App)
fn dispose(self: RenderHandle<Self>, app: &mut App)
Flutter’s dispose: drop the clip layer handle, then super.dispose().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".