pub trait RenderSliverBoxChildManager {
// Required methods
fn create_child(
&self,
app: &mut App,
index: i32,
after: Option<AnyRenderBox>,
);
fn remove_child(&self, app: &mut App, child: AnyRenderBox);
fn estimate_max_scroll_offset(
&self,
app: &App,
constraints: SliverConstraints,
first_index: Option<i32>,
last_index: Option<i32>,
leading_scroll_offset: Option<f64>,
trailing_scroll_offset: Option<f64>,
) -> f64;
fn child_count(&self, app: &mut App) -> i32;
fn did_adopt_child(&self, app: &mut App, child: AnyRenderBox);
fn set_did_underflow(&self, app: &mut App, value: bool);
// Provided methods
fn estimated_child_count(&self, app: &App) -> Option<i32> { ... }
fn did_start_layout(&self, app: &mut App) { ... }
fn did_finish_layout(&self, app: &mut App) { ... }
fn debug_assert_child_list_locked(&self, app: &App) -> bool { ... }
}Expand description
A delegate used by RenderSliverMultiBoxAdaptor to manage its children.
RenderSliverMultiBoxAdaptor objects reify their children lazily to avoid spending
resources on children that are not visible in the viewport. This delegate lets these objects
create and remove children as well as estimate the total scroll offset extent occupied by the
full child list.
The widget layer implements this; the render object holds it as an
Rc<dyn RenderSliverBoxChildManager>.
Required Methods§
Sourcefn create_child(&self, app: &mut App, index: i32, after: Option<AnyRenderBox>)
fn create_child(&self, app: &mut App, index: i32, after: Option<AnyRenderBox>)
Called during layout when a new child is needed.
The child should be inserted into the child list in the appropriate position, after the
after child (at the start of the list if after is None). Its index and scroll
offsets will automatically be set appropriately.
The index argument gives the index of the child to show. It is possible for negative
indices to be requested. For example: if the user scrolls from child 0 to child 10, and
then those children get much smaller, and then the user scrolls back up again, this
method will eventually be asked to produce a child for index -1.
If no child corresponds to index, then do nothing.
Which child is indicated by index zero depends on the
crate::GrowthDirection specified in the constraints of the
RenderSliverMultiBoxAdaptor.
During a call to this method it is valid to remove other children from the
RenderSliverMultiBoxAdaptor object if they were not created during this frame and have
not yet been updated during this frame. It is not valid to add any other children to this
render object.
Sourcefn remove_child(&self, app: &mut App, child: AnyRenderBox)
fn remove_child(&self, app: &mut App, child: AnyRenderBox)
Remove the given child from the child list.
Called by RenderSliverMultiBoxAdaptor::collect_garbage, which itself is called from
the adaptor’s perform_layout.
The index of the given child can be obtained using
RenderSliverMultiBoxAdaptor::index_of.
Sourcefn estimate_max_scroll_offset(
&self,
app: &App,
constraints: SliverConstraints,
first_index: Option<i32>,
last_index: Option<i32>,
leading_scroll_offset: Option<f64>,
trailing_scroll_offset: Option<f64>,
) -> f64
fn estimate_max_scroll_offset( &self, app: &App, constraints: SliverConstraints, first_index: Option<i32>, last_index: Option<i32>, leading_scroll_offset: Option<f64>, trailing_scroll_offset: Option<f64>, ) -> f64
Called to estimate the total scrollable extents of this object.
Must return the total distance from the start of the child with the earliest possible index to the end of the child with the last possible index.
Sourcefn child_count(&self, app: &mut App) -> i32
fn child_count(&self, app: &mut App) -> i32
Called to obtain a precise measure of the total number of children.
Must return the number that is one greater than the greatest index for which
create_child will actually create a child.
This is used when create_child cannot add a child for a positive index, to determine
the precise dimensions of the sliver. It will not be called if create_child is always
able to create a child (e.g. for an infinite list).
Sourcefn did_adopt_child(&self, app: &mut App, child: AnyRenderBox)
fn did_adopt_child(&self, app: &mut App, child: AnyRenderBox)
Called during RenderSliverMultiBoxAdaptor::insert or
RenderSliverMultiBoxAdaptor::move_child.
Implementors must ensure that the SliverMultiBoxAdaptorParentData::index field of the
child’s parent data accurately reflects the child’s index in the child list after this
function returns.
Sourcefn set_did_underflow(&self, app: &mut App, value: bool)
fn set_did_underflow(&self, app: &mut App, value: bool)
Called during layout to indicate whether this object provided insufficient children for
the RenderSliverMultiBoxAdaptor to fill the
SliverConstraints::remaining_paint_extent.
Typically called unconditionally at the start of layout with false and then later
called with true when the adaptor fails to create a child required to fill the
remaining paint extent.
Provided Methods§
Sourcefn estimated_child_count(&self, app: &App) -> Option<i32>
fn estimated_child_count(&self, app: &App) -> Option<i32>
The best available estimate of child_count, or None if no
estimate is available.
Sourcefn did_start_layout(&self, app: &mut App)
fn did_start_layout(&self, app: &mut App)
Called at the beginning of layout to indicate that layout is about to occur.
Sourcefn did_finish_layout(&self, app: &mut App)
fn did_finish_layout(&self, app: &mut App)
Called at the end of layout to indicate that layout is now complete.
Sourcefn debug_assert_child_list_locked(&self, app: &App) -> bool
fn debug_assert_child_list_locked(&self, app: &App) -> bool
In debug mode, asserts that this manager is not expecting any modifications to the
RenderSliverMultiBoxAdaptor’s child list.
This function always returns true.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".