pub trait SliverGridDelegate: Debug {
// Required methods
fn get_layout(
&self,
constraints: SliverConstraints,
) -> Box<dyn SliverGridLayout>;
fn should_relayout(&self, old_delegate: &dyn SliverGridDelegate) -> bool;
fn as_any(&self) -> &dyn Any;
}Expand description
Controls the layout of tiles in a grid.
Given the current constraints on the grid, a SliverGridDelegate computes the layout for
the tiles in the grid. The tiles can be placed arbitrarily, but it is more efficient to place
tiles roughly in order by scroll offset because grids reify a contiguous sequence of children.
See also:
SliverGridDelegateWithFixedCrossAxisCount, which creates a layout with a fixed number of tiles in the cross axis.SliverGridDelegateWithMaxCrossAxisExtent, which creates a layout with tiles that have a maximum cross-axis extent.GridView, which uses this delegate to control the layout of its tiles.SliverGrid, which uses this delegate to control the layout of its tiles.RenderSliverGrid, which uses this delegate to control the layout of its tiles.
Required Methods§
Sourcefn get_layout(
&self,
constraints: SliverConstraints,
) -> Box<dyn SliverGridLayout>
fn get_layout( &self, constraints: SliverConstraints, ) -> Box<dyn SliverGridLayout>
Returns information about the size and position of the tiles in the grid.
Sourcefn should_relayout(&self, old_delegate: &dyn SliverGridDelegate) -> bool
fn should_relayout(&self, old_delegate: &dyn SliverGridDelegate) -> bool
Override this method to return true when the children need to be laid out.
This should compare the fields of the current delegate and the given old_delegate and
return true if the fields are such that the layout would be different. The grid asks only
for an old_delegate of this delegate’s own type.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".