Skip to main content

RefreshIndicator

Struct RefreshIndicator 

Source
pub struct RefreshIndicator {
Show 14 fields pub key: Option<KeyRef>, pub child: WidgetRef, pub displacement: f64, pub edge_offset: f64, pub on_refresh: RefreshCallback, pub on_status_change: Option<ValueChanged<Option<RefreshIndicatorStatus>>>, pub color: Option<Color>, pub background_color: Option<Color>, pub notification_predicate: ScrollNotificationPredicate, pub semantics_label: Option<String>, pub semantics_value: Option<String>, pub stroke_width: f64, pub trigger_mode: RefreshIndicatorTriggerMode, pub elevation: f64, /* private fields */
}
Expand description

A widget that supports the Material “swipe to refresh” idiom.

When the child’s scrollable descendant overscrolls, an animated circular progress indicator is faded into view. When the scroll ends, if the indicator has been dragged far enough for it to become completely opaque, the on_refresh callback is called. The callback is expected to update the scrollable’s contents and then complete the task it returns. The refresh indicator disappears after the callback’s task has completed.

The trigger mode is configured by RefreshIndicator::trigger_mode.

§Troubleshooting

§Refresh indicator does not show up

The RefreshIndicator will appear if its scrollable descendant can be overscrolled, i.e. if the scrollable’s content is bigger than its viewport. To ensure that the RefreshIndicator will always appear, even if the scrollable’s content fits within its viewport, set the scrollable’s physics to AlwaysScrollableScrollPhysics.

See also:

Fields§

§key: Option<KeyRef>§child: WidgetRef

The widget below this widget in the tree.

The refresh indicator will be stacked on top of this child. The indicator will appear when the child’s scrollable descendant is over-scrolled.

§displacement: f64

The distance from the child’s top or bottom edge_offset where the refresh indicator will settle.

§edge_offset: f64

The offset where the refresh indicator starts to appear on drag start.

§on_refresh: RefreshCallback

A function that is called when the user has dragged the refresh indicator far enough to demonstrate that they want the app to refresh.

§on_status_change: Option<ValueChanged<Option<RefreshIndicatorStatus>>>

Called to get the current status of the refresh indicator to update the UI as needed.

Dart declares this on the RefreshIndicator.noSpinner constructor only; here every constructor shares the field, so any of them can set it (PORTING.md).

§color: Option<Color>

The progress indicator’s foreground color.

§background_color: Option<Color>

The progress indicator’s background color.

§notification_predicate: ScrollNotificationPredicate

Whether a ScrollNotification should be handled by this widget.

§semantics_label: Option<String>

The progress indicator’s semantics label.

§semantics_value: Option<String>

The progress indicator’s semantics value.

§stroke_width: f64

The refresh indicator’s stroke width.

§trigger_mode: RefreshIndicatorTriggerMode

How this refresh indicator can be triggered when users overscroll.

§elevation: f64

The elevation of the underlying refresh indicator.

Implementations§

Source§

impl RefreshIndicator

Source

pub fn new<K>( on_refresh: RefreshCallback, child: impl IntoWidget<K>, ) -> RefreshIndicator

Creates a refresh indicator; Dart’s optional named arguments are the setters.

Source

pub fn adaptive<K>( on_refresh: RefreshCallback, child: impl IntoWidget<K>, ) -> RefreshIndicator

Creates an adaptive refresh indicator: a Cupertino activity indicator on iOS and macOS, and a Material one elsewhere.

Source

pub fn no_spinner<K>( on_refresh: RefreshCallback, child: impl IntoWidget<K>, ) -> RefreshIndicator

Creates a refresh indicator with no spinner that calls on_refresh when successfully armed by a drag event.

Source

pub fn key(self, key: KeyRef) -> RefreshIndicator

Dart RefreshIndicator(key:).

Source

pub fn displacement(self, displacement: f64) -> RefreshIndicator

Dart RefreshIndicator(displacement:).

Source

pub fn edge_offset(self, edge_offset: f64) -> RefreshIndicator

Dart RefreshIndicator(edgeOffset:).

Source

pub fn on_status_change( self, on_status_change: ValueChanged<Option<RefreshIndicatorStatus>>, ) -> RefreshIndicator

Dart RefreshIndicator(onStatusChange:).

Source

pub fn color(self, color: Color) -> RefreshIndicator

Dart RefreshIndicator(color:).

Source

pub fn background_color(self, background_color: Color) -> RefreshIndicator

Dart RefreshIndicator(backgroundColor:).

Source

pub fn notification_predicate( self, notification_predicate: ScrollNotificationPredicate, ) -> RefreshIndicator

Dart RefreshIndicator(notificationPredicate:).

Source

pub fn semantics_label( self, semantics_label: impl Into<String>, ) -> RefreshIndicator

Dart RefreshIndicator(semanticsLabel:).

Source

pub fn semantics_value( self, semantics_value: impl Into<String>, ) -> RefreshIndicator

Dart RefreshIndicator(semanticsValue:).

Source

pub fn stroke_width(self, stroke_width: f64) -> RefreshIndicator

Dart RefreshIndicator(strokeWidth:).

Source

pub fn trigger_mode( self, trigger_mode: RefreshIndicatorTriggerMode, ) -> RefreshIndicator

Dart RefreshIndicator(triggerMode:).

Source

pub fn elevation(self, elevation: f64) -> RefreshIndicator

Dart RefreshIndicator(elevation:).

Trait Implementations§

Source§

impl Debug for RefreshIndicator

Source§

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

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

impl StatefulWidget for RefreshIndicator

Source§

type State = RefreshIndicatorState

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn create_state(&self) -> RefreshIndicatorState

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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 debug_check_constructor(&self)

Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Source§

fn type_name(&self) -> &'static str

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

§

impl !Send for RefreshIndicator

§

impl !Sync for RefreshIndicator

§

impl !UnwindSafe for RefreshIndicator

§

impl Forget for RefreshIndicator

§

impl Freeze for RefreshIndicator
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, *const RcInner<dyn Fn(&mut App) -> Task<()>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App) -> Task<()>>>: Freeze, *const RcInner<dyn Fn(&mut App, Option<RefreshIndicatorStatus>)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, Option<RefreshIndicatorStatus>)>>: Freeze, *const RcInner<dyn Fn(&(dyn ScrollNotification + 'static)) -> bool> is !null: Freeze, PhantomData<RcInner<dyn Fn(&(dyn ScrollNotification + 'static)) -> bool>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for RefreshIndicator

§

impl Unpin for RefreshIndicator
where Rc<dyn Key>: Unpin, Rc<dyn Widget>: Unpin, Rc<dyn Fn(&mut App) -> Task<()>>: Unpin, Rc<dyn Fn(&mut App, Option<RefreshIndicatorStatus>)>: Unpin, Rc<dyn Fn(&(dyn ScrollNotification + 'static)) -> bool>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for RefreshIndicator
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App) -> Task<()>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App) -> Task<()>>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, Option<RefreshIndicatorStatus>)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, Option<RefreshIndicatorStatus>)>>: UnsafeUnpin, *const RcInner<dyn Fn(&(dyn ScrollNotification + 'static)) -> bool> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&(dyn ScrollNotification + 'static)) -> bool>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin,

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<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
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>