Skip to main content

SliverChildListDelegate

Struct SliverChildListDelegate 

Source
pub struct SliverChildListDelegate {
    pub add_automatic_keep_alives: bool,
    pub add_repaint_boundaries: bool,
    pub add_semantic_indexes: bool,
    pub semantic_index_offset: i32,
    pub semantic_index_callback: SemanticIndexCallback,
    pub children: Vec<WidgetRef>,
    /* private fields */
}
Expand description

A delegate that supplies children for slivers using an explicit list.

Many slivers lazily construct their box children to avoid creating more children than are visible through the Viewport. This delegate provides children using an explicit list, which is convenient but reduces the benefit of building children lazily.

In general building all the widgets in advance is not efficient. It is better to create a delegate that builds them on demand using SliverChildBuilderDelegate or by implementing SliverChildDelegate directly.

This type is provided for the cases where either the list of children is known well in advance, and therefore will not be built each time the delegate itself is created, or the list is small, such that it’s likely always visible (and thus there is nothing to be gained by building it on demand). For example, the body of a dialog box might fit both of these conditions.

The widgets in the given children list are automatically wrapped in AutomaticKeepAlive widgets if add_automatic_keep_alives is true (the default) and in RepaintBoundary widgets if add_repaint_boundaries is true (also the default).

§Accessibility

CustomScrollView requires that its semantic children are annotated using IndexedSemantics. This is done by default in the delegate with the add_semantic_indexes parameter set to true.

See also:

Fields§

§add_automatic_keep_alives: bool

Whether to wrap each child in an AutomaticKeepAlive.

§add_repaint_boundaries: bool

Whether to wrap each child in a RepaintBoundary.

§add_semantic_indexes: bool

Whether to wrap each child in an IndexedSemantics.

§semantic_index_offset: i32

An initial offset to add to the semantic indexes generated by this widget.

§semantic_index_callback: SemanticIndexCallback

A SemanticIndexCallback which is used when add_semantic_indexes is true.

§children: Vec<WidgetRef>

The widgets to display.

If this list is going to be mutated, it is usually wise to put a Key on each of the child widgets, so that the framework can match old configurations to new configurations and maintain the underlying render objects.

A widget is immutable, so a new list must be provided whenever the children change.

Implementations§

Source§

impl SliverChildListDelegate

Source

pub fn new(children: Vec<WidgetRef>) -> SliverChildListDelegate

Creates a delegate that supplies children for slivers using the given list.

If the order of children never changes, consider using fixed.

Source

pub fn fixed(children: Vec<WidgetRef>) -> SliverChildListDelegate

Creates a constant version of the delegate that supplies children for slivers using the given list.

If the order of the children will change, consider using new.

Source

pub fn add_automatic_keep_alives(self, value: bool) -> SliverChildListDelegate

Dart SliverChildListDelegate(addAutomaticKeepAlives:).

Source

pub fn add_repaint_boundaries(self, value: bool) -> SliverChildListDelegate

Dart SliverChildListDelegate(addRepaintBoundaries:).

Source

pub fn add_semantic_indexes(self, value: bool) -> SliverChildListDelegate

Dart SliverChildListDelegate(addSemanticIndexes:).

Source

pub fn semantic_index_offset(self, value: i32) -> SliverChildListDelegate

Dart SliverChildListDelegate(semanticIndexOffset:).

Source

pub fn semantic_index_callback( self, value: SemanticIndexCallback, ) -> SliverChildListDelegate

Dart SliverChildListDelegate(semanticIndexCallback:).

Source

pub fn into_delegate(self) -> SliverChildDelegateRef

The delegate as the shared reference a sliver widget takes.

Trait Implementations§

Source§

impl Debug for SliverChildListDelegate

Source§

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

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

impl SliverChildDelegate for SliverChildListDelegate

Source§

fn find_index_by_key(&self, key: &KeyRef) -> Option<i32>

Find index of child element with associated key. Read more
Source§

fn build( &self, _app: &mut App, _context: BuildContext, index: i32, ) -> Option<WidgetRef>

Returns the child with the given index. Read more
Source§

fn estimated_child_count(&self) -> Option<i32>

Returns an estimate of the number of children this delegate will build. Read more
Source§

fn should_rebuild(&self, old_delegate: &dyn SliverChildDelegate) -> bool

Called whenever a new instance of the child delegate class is provided to the sliver. Read more
Source§

fn as_any(&self) -> &dyn Any

The concrete delegate, for Dart’s oldDelegate as Foo.
Source§

fn estimate_max_scroll_offset( &self, first_index: i32, last_index: i32, leading_scroll_offset: f64, trailing_scroll_offset: f64, ) -> Option<f64>

Returns an estimate of the max scroll extent for all the children. Read more
Source§

fn did_finish_layout(&self, first_index: i32, last_index: i32)

Called at the end of layout to indicate that layout is now complete. Read more
Source§

fn delegate_type(&self) -> TypeId

The concrete delegate’s type, Dart’s runtimeType.
Source§

fn debug_fill_description(&self, description: &mut Vec<String>)

Add additional information to the given description for use by toString.

Auto Trait Implementations§

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<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>