pub struct CarouselView {Show 22 fields
pub key: Option<KeyRef>,
pub padding: Option<EdgeInsets>,
pub background_color: Option<Color>,
pub elevation: Option<f64>,
pub shape: Option<ShapeBorderRef>,
pub item_clip_behavior: Option<Clip>,
pub overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>,
pub shrink_extent: f64,
pub item_snapping: bool,
pub controller: Option<Ref<CarouselController>>,
pub scroll_direction: Axis,
pub reverse: bool,
pub consume_max_weight: bool,
pub on_tap: Option<ValueChanged<i32>>,
pub enable_splash: bool,
pub item_extent: Option<f64>,
pub flex_weights: Option<Vec<i32>>,
pub children: Vec<WidgetRef>,
pub on_index_changed: Option<ValueChanged<i32>>,
pub item_builder: Option<CarouselItemBuilder>,
pub item_count: Option<i32>,
pub infinite: bool,
}Expand description
A Material Design carousel widget.
The CarouselView presents a scrollable list of items, each of which can dynamically
change size based on the chosen layout.
Material Design 3 introduced 4 carousel layouts:
- Multi-browse and uncontained:
CarouselView::newwith anitem_extent— the items have the same maximum extent and shrink to a smaller one as they reach the edges. - Hero and center-aligned hero:
CarouselView::weighted, whose items’ extents follow theflex_weights.
The CarouselView::builder and CarouselView::weighted_builder constructors build their
items lazily; with infinite set, the list repeats its items forever.
The properties of the items’ Material that are None come from the
CarouselViewTheme, and then from the defaults documented on
each field.
See also:
CarouselController, which controls the scroll position of this widget.PageView, which is a scrollable list that works page by page.
Fields§
§key: Option<KeyRef>§padding: Option<EdgeInsets>The amount of space surrounding each carousel item.
Defaults to EdgeInsets::all(4.0).
background_color: Option<Color>The background color for each carousel item.
Defaults to ColorScheme::surface.
elevation: Option<f64>The z-coordinate of each carousel item.
Defaults to 0.0.
shape: Option<ShapeBorderRef>The shape of each carousel item’s Material.
Defaults to a RoundedRectangleBorder with a circular corner radius of 28.0.
item_clip_behavior: Option<Clip>The clip behavior for each carousel item.
Defaults to Clip::AntiAlias.
overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>The highlight color to indicate the carousel items are in pressed, hovered or focused states.
Defaults to ColorScheme::onSurface with opacities of 0.1 (pressed), 0.08 (hovered)
and 0.1 (focused).
shrink_extent: f64The minimum allowable extent (size) in the main axis for carousel items in the viewport.
As the carousel scrolls, the first visible item is pinned and gradually shrinks to
shrink_extent before disappearing.
Defaults to 0.0.
item_snapping: boolThe scroll position snaps to the nearest item when scrolling ends.
Defaults to false.
controller: Option<Ref<CarouselController>>An object that can be used to control the position to which this scroll view is scrolled.
scroll_direction: AxisThe Axis along which the scroll view’s offset increases with each item.
Defaults to Axis::Horizontal.
reverse: boolWhether the carousel list scrolls in the reading direction.
Defaults to false.
consume_max_weight: boolWhether the items scroll past the position of the largest weight so that every item has a chance to be the largest. Only meaningful for the weighted constructors.
Defaults to true.
on_tap: Option<ValueChanged<i32>>Called when one of the items is tapped, with its index.
enable_splash: boolWhether the items show the ink splash and the overlay colors when they are tapped, hovered or focused.
Defaults to true.
item_extent: Option<f64>The extent the children are forced to have in the main axis. Set by
CarouselView::new and CarouselView::builder.
flex_weights: Option<Vec<i32>>The weights that determine the extent of each item. Set by CarouselView::weighted
and CarouselView::weighted_builder.
children: Vec<WidgetRef>The child widgets for the carousel; empty for the builder constructors.
on_index_changed: Option<ValueChanged<i32>>Called when the leading item changes while the carousel is scrolled.
item_builder: Option<CarouselItemBuilder>The builder of the builder constructors, which build the items lazily.
item_count: Option<i32>The number of items the builder constructors can build; None means as many as the
builder answers.
infinite: boolWhether the carousel loops its items forever.
Defaults to false.
Implementations§
Source§impl CarouselView
impl CarouselView
Sourcepub fn new(item_extent: f64, children: Vec<WidgetRef>) -> CarouselView
pub fn new(item_extent: f64, children: Vec<WidgetRef>) -> CarouselView
Creates a Material Design carousel whose items all have the extent item_extent.
Sourcepub fn weighted(
flex_weights: Vec<i32>,
children: Vec<WidgetRef>,
) -> CarouselView
pub fn weighted( flex_weights: Vec<i32>, children: Vec<WidgetRef>, ) -> CarouselView
Creates a Material Design carousel whose items’ extents follow flex_weights.
The length of flex_weights is how many items fit in the viewport at a time.
Sourcepub fn builder(
item_extent: f64,
item_builder: CarouselItemBuilder,
) -> CarouselView
pub fn builder( item_extent: f64, item_builder: CarouselItemBuilder, ) -> CarouselView
Creates a Material Design carousel that builds its items lazily, each with the extent
item_extent.
Sourcepub fn weighted_builder(
flex_weights: Vec<i32>,
item_builder: CarouselItemBuilder,
) -> CarouselView
pub fn weighted_builder( flex_weights: Vec<i32>, item_builder: CarouselItemBuilder, ) -> CarouselView
Creates a Material Design carousel that builds its items lazily, with extents that
follow flex_weights.
Sourcepub fn key(self, key: KeyRef) -> CarouselView
pub fn key(self, key: KeyRef) -> CarouselView
Dart CarouselView(key:).
Sourcepub fn padding(self, padding: EdgeInsets) -> CarouselView
pub fn padding(self, padding: EdgeInsets) -> CarouselView
Dart CarouselView(padding:).
Sourcepub fn background_color(self, background_color: Color) -> CarouselView
pub fn background_color(self, background_color: Color) -> CarouselView
Dart CarouselView(backgroundColor:).
Sourcepub fn elevation(self, elevation: f64) -> CarouselView
pub fn elevation(self, elevation: f64) -> CarouselView
Dart CarouselView(elevation:).
Sourcepub fn shape(self, shape: impl Into<ShapeBorderRef>) -> CarouselView
pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> CarouselView
Dart CarouselView(shape:).
Sourcepub fn item_clip_behavior(self, item_clip_behavior: Clip) -> CarouselView
pub fn item_clip_behavior(self, item_clip_behavior: Clip) -> CarouselView
Dart CarouselView(itemClipBehavior:).
Sourcepub fn overlay_color(
self,
overlay_color: WidgetStatePropertyRef<Option<Color>>,
) -> CarouselView
pub fn overlay_color( self, overlay_color: WidgetStatePropertyRef<Option<Color>>, ) -> CarouselView
Dart CarouselView(overlayColor:).
Sourcepub fn item_snapping(self, item_snapping: bool) -> CarouselView
pub fn item_snapping(self, item_snapping: bool) -> CarouselView
Dart CarouselView(itemSnapping:).
Sourcepub fn shrink_extent(self, shrink_extent: f64) -> CarouselView
pub fn shrink_extent(self, shrink_extent: f64) -> CarouselView
Dart CarouselView(shrinkExtent:).
Sourcepub fn controller(self, controller: Ref<CarouselController>) -> CarouselView
pub fn controller(self, controller: Ref<CarouselController>) -> CarouselView
Dart CarouselView(controller:).
Sourcepub fn scroll_direction(self, scroll_direction: Axis) -> CarouselView
pub fn scroll_direction(self, scroll_direction: Axis) -> CarouselView
Dart CarouselView(scrollDirection:).
Sourcepub fn reverse(self, reverse: bool) -> CarouselView
pub fn reverse(self, reverse: bool) -> CarouselView
Dart CarouselView(reverse:).
Sourcepub fn consume_max_weight(self, consume_max_weight: bool) -> CarouselView
pub fn consume_max_weight(self, consume_max_weight: bool) -> CarouselView
Dart CarouselView.weighted(consumeMaxWeight:).
Sourcepub fn on_tap(self, on_tap: ValueChanged<i32>) -> CarouselView
pub fn on_tap(self, on_tap: ValueChanged<i32>) -> CarouselView
Dart CarouselView(onTap:).
Sourcepub fn enable_splash(self, enable_splash: bool) -> CarouselView
pub fn enable_splash(self, enable_splash: bool) -> CarouselView
Dart CarouselView(enableSplash:).
Sourcepub fn on_index_changed(
self,
on_index_changed: ValueChanged<i32>,
) -> CarouselView
pub fn on_index_changed( self, on_index_changed: ValueChanged<i32>, ) -> CarouselView
Dart CarouselView(onIndexChanged:).
Sourcepub fn item_count(self, item_count: i32) -> CarouselView
pub fn item_count(self, item_count: i32) -> CarouselView
Dart CarouselView.builder(itemCount:).
Sourcepub fn infinite(self, infinite: bool) -> CarouselView
pub fn infinite(self, infinite: bool) -> CarouselView
Dart CarouselView(infinite:).
Trait Implementations§
Source§impl Debug for CarouselView
impl Debug for CarouselView
Source§impl StatefulWidget for CarouselView
impl StatefulWidget for CarouselView
Source§type State = CarouselViewState
type State = CarouselViewState
Source§fn create_state(&self) -> CarouselViewState
fn create_state(&self) -> CarouselViewState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl !RefUnwindSafe for CarouselView
impl !Send for CarouselView
impl !Sync for CarouselView
impl !UnwindSafe for CarouselView
impl Forget for CarouselView
impl Freeze for CarouselViewwhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const RcInner<dyn ShapeBorder> is !null: Freeze,
PhantomData<RcInner<dyn ShapeBorder>>: Freeze,
*const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: Freeze,
PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: Freeze,
NonZero<u32>: Freeze,
PhantomData<fn() -> CarouselController>: Freeze,
*const RcInner<Keep> is !null: Freeze,
PhantomData<RcInner<Keep>>: Freeze,
*const RcInner<dyn Fn(&mut App, i32)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, i32)>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<i32>: Freeze,
PhantomData<Rc<dyn Widget>>: Freeze,
*const RcInner<dyn Fn(&mut App, AnyElement, i32) -> Option<Rc<dyn Widget>>> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, AnyElement, i32) -> Option<Rc<dyn Widget>>>>: Freeze,
impl Move for CarouselView
impl Unpin for CarouselView
impl UnsafeUnpin for CarouselViewwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn ShapeBorder> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn ShapeBorder>>: UnsafeUnpin,
*const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
PhantomData<fn() -> CarouselController>: UnsafeUnpin,
*const RcInner<Keep> is !null: UnsafeUnpin,
PhantomData<RcInner<Keep>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, i32)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, i32)>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<i32>: UnsafeUnpin,
PhantomData<Rc<dyn Widget>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, AnyElement, i32) -> Option<Rc<dyn Widget>>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, AnyElement, i32) -> Option<Rc<dyn Widget>>>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.