pub trait SliverPersistentHeaderDelegate: Debug + 'static {
// Required methods
fn build(
&self,
app: &mut App,
context: BuildContext,
shrink_offset: f64,
overlaps_content: bool,
) -> WidgetRef;
fn min_extent(&self) -> f64;
fn max_extent(&self) -> f64;
fn should_rebuild(
&self,
old_delegate: &dyn SliverPersistentHeaderDelegate,
) -> bool;
fn as_any(&self) -> &dyn Any;
// Provided methods
fn vsync(&self) -> Option<TickerProviderRef> { ... }
fn snap_configuration(&self) -> Option<FloatingHeaderSnapConfiguration> { ... }
fn stretch_configuration(
&self,
) -> Option<OverScrollHeaderStretchConfiguration> { ... }
fn show_on_screen_configuration(
&self,
) -> Option<PersistentHeaderShowOnScreenConfiguration> { ... }
fn delegate_type(&self) -> TypeId { ... }
}Expand description
Delegate for configuring a SliverPersistentHeader.
Required Methods§
Sourcefn build(
&self,
app: &mut App,
context: BuildContext,
shrink_offset: f64,
overlaps_content: bool,
) -> WidgetRef
fn build( &self, app: &mut App, context: BuildContext, shrink_offset: f64, overlaps_content: bool, ) -> WidgetRef
The widget to place inside the SliverPersistentHeader.
The context is the BuildContext of the sliver.
The shrink_offset is a distance from max_extent towards
min_extent representing the current amount by which the sliver has
been shrunk. When the shrink offset is zero, the contents will be rendered with a
dimension of max_extent in the main axis. When it equals the difference between
max_extent and min_extent (a positive number), the contents will be rendered with a
dimension of min_extent in the main axis. The shrink offset will always be a positive
number in that range.
The overlaps_content argument is true if subsequent slivers (if any) will be rendered
beneath this one, and false if the sliver will not have any contents below it. Typically
this is used to decide whether to draw a shadow to simulate the sliver being above the
contents below it.
Sourcefn min_extent(&self) -> f64
fn min_extent(&self) -> f64
The smallest size to allow the header to reach, when it shrinks at the start of the viewport.
This must return a value equal to or less than max_extent.
This value should not change over the lifetime of the delegate. It should be based
entirely on the constructor arguments passed to the delegate. See
should_rebuild, which must return true if a new delegate would
return a different value.
Sourcefn max_extent(&self) -> f64
fn max_extent(&self) -> f64
The size of the header when it is not shrinking at the top of the viewport.
This must return a value equal to or greater than min_extent.
Sourcefn should_rebuild(
&self,
old_delegate: &dyn SliverPersistentHeaderDelegate,
) -> bool
fn should_rebuild( &self, old_delegate: &dyn SliverPersistentHeaderDelegate, ) -> bool
Whether this delegate is meaningfully different from the old delegate.
If this returns false, then the header might not be rebuilt, even though the instance of the delegate changed.
This must return true if old_delegate and this object would return different values for
min_extent, max_extent,
snap_configuration, or would return a meaningfully different
widget tree from build for the same arguments.
Dart’s covariant SliverPersistentHeaderDelegate oldDelegate: the caller has already
compared delegate_type, so the argument downcasts through
as_any.
Provided Methods§
Sourcefn vsync(&self) -> Option<TickerProviderRef>
fn vsync(&self) -> Option<TickerProviderRef>
A TickerProvider to use when animating the header’s size changes.
Must not be None if the persistent header is a floating header, and
snap_configuration or
show_on_screen_configuration is not None.
Sourcefn snap_configuration(&self) -> Option<FloatingHeaderSnapConfiguration>
fn snap_configuration(&self) -> Option<FloatingHeaderSnapConfiguration>
Specifies how floating headers should animate in and out of view.
If the value of this property is None, then floating headers will not animate into
place.
This is only used for floating headers (those with SliverPersistentHeader::floating
set to true).
Sourcefn stretch_configuration(&self) -> Option<OverScrollHeaderStretchConfiguration>
fn stretch_configuration(&self) -> Option<OverScrollHeaderStretchConfiguration>
Specifies a callback and offset for execution.
If the value of this property is None, then the callback will not be triggered.
This is only used for stretching headers.
Sourcefn show_on_screen_configuration(
&self,
) -> Option<PersistentHeaderShowOnScreenConfiguration>
fn show_on_screen_configuration( &self, ) -> Option<PersistentHeaderShowOnScreenConfiguration>
Specifies how floating headers and pinned headers should behave in response to
RenderObject::show_on_screen calls.
Sourcefn delegate_type(&self) -> TypeId
fn delegate_type(&self) -> TypeId
The concrete delegate’s type, Dart’s runtimeType.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".