Skip to main content

LinearProgressIndicator

Struct LinearProgressIndicator 

Source
pub struct LinearProgressIndicator {
    pub progress_indicator: ProgressIndicatorData,
    pub min_height: Option<f64>,
    pub border_radius: Option<BorderRadiusGeometry>,
    pub stop_indicator_color: Option<Color>,
    pub stop_indicator_radius: Option<f64>,
    pub track_gap: Option<f64>,
    pub year2023: Option<bool>,
    pub controller: Option<Ref<AnimationController>>,
}
Expand description

A Material Design linear progress indicator, also known as a progress bar.

A widget that shows progress along a line. There are two kinds of linear progress indicators:

  • Determinate. Determinate progress indicators have a specific value at each point in time, and the value should increase monotonically from 0.0 to 1.0, at which time the indicator is complete. To create a determinate progress indicator, use a non-null value between 0.0 and 1.0.
  • Indeterminate. Indeterminate progress indicators do not have a specific value at each point in time and instead indicate that progress is being made without indicating how much progress remains. To create an indeterminate progress indicator, use a null value.

The indicator line is displayed with value_color, an animated value. To specify a constant color value use: AlwaysStoppedAnimation::new(Some(color)).

The minimum height of the indicator can be specified using min_height. The indicator can be made taller by wrapping the widget with a SizedBox.

§Animation synchronization

When multiple CircularProgressIndicators or LinearProgressIndicators are animating on screen simultaneously (e.g., in a list of loading items), their uncoordinated animations can appear visually cluttered. To address this, the animation of an indicator can be driven by a custom AnimationController.

This allows multiple indicators to be synchronized to a single animation source. The most convenient way to achieve this for a group of indicators is by providing a controller via ProgressIndicatorTheme (see ProgressIndicatorThemeData::controller). All CircularProgressIndicators or LinearProgressIndicators within that theme’s subtree will then share the same animation, resulting in a more coordinated and visually pleasing effect.

Alternatively, a specific AnimationController can be passed directly to the controller property of an individual indicator.

See also:

Fields§

§progress_indicator: ProgressIndicatorData

The base class’s fields.

Its background_color is the color of the track being filled by the linear indicator. If it is null then the ambient ProgressIndicatorThemeData::linear_track_color will be used. If that is null, then the ambient theme’s ColorScheme::background will be used to draw the track.

§min_height: Option<f64>

The minimum height of the line used to draw the linear indicator.

If min_height is null then it will use the ambient ProgressIndicatorThemeData::linear_min_height. If that is null it will use 4dp.

§border_radius: Option<BorderRadiusGeometry>

The border radius of both the indicator and the track.

If null, then the ProgressIndicatorThemeData::border_radius will be used. If that is also null, then defaults to radius of 2, which produces a rounded shape with a rounded indicator. If ThemeData::use_material3 is false, then defaults to BorderRadius::ZERO, which produces a rectangular shape with a rectangular indicator.

§stop_indicator_color: Option<Color>

The color of the stop indicator.

If year2023 is true or ThemeData::use_material3 is false, then no stop indicator will be drawn.

If null, then the ProgressIndicatorThemeData::stop_indicator_color will be used. If that is null, then the ColorScheme::primary will be used.

§stop_indicator_radius: Option<f64>

The radius of the stop indicator.

If year2023 is true or ThemeData::use_material3 is false, then no stop indicator will be drawn.

Set stop_indicator_radius to 0 to hide the stop indicator.

If null, then the ProgressIndicatorThemeData::stop_indicator_radius will be used. If that is null, then defaults to 2.

§track_gap: Option<f64>

The gap between the indicator and the track.

If year2023 is true or ThemeData::use_material3 is false, then no track gap will be drawn.

Set track_gap to 0 to hide the track gap.

If null, then the ProgressIndicatorThemeData::track_gap will be used. If that is null, then defaults to 4.

§year2023: Option<bool>
👎Deprecated:

Set this flag to false to opt into the 2024 progress indicator appearance. Defaults to true. In the future, this flag will default to false. Use ProgressIndicatorThemeData to customize individual properties. This feature was deprecated after v3.27.0-0.1.pre.

When true, the LinearProgressIndicator will use the 2023 Material Design 3 appearance.

If null, then the ProgressIndicatorThemeData::year2023 will be used. If that is null, then defaults to true.

If this is set to false, the LinearProgressIndicator will use the latest Material Design 3 appearance, which was introduced in December 2023.

If ThemeData::use_material3 is false, then this property is ignored.

§controller: Option<Ref<AnimationController>>

An optional AnimationController that controls the animation of this indeterminate progress indicator.

This controller is only used when the indicator is indeterminate (i.e., when value is null). If this property is non-null, value must be null.

The controller’s value is expected to be a linear progression from 0.0 to 1.0, which represents one full cycle of the indeterminate animation.

If this controller is null (and value is also null), the widget will look for a ProgressIndicatorThemeData::controller. If that is also null, the widget will create and manage its own internal AnimationController to drive the default indeterminate animation.

See also:

Implementations§

Source§

impl LinearProgressIndicator

Source

pub const DEFAULT_ANIMATION_DURATION: Duration

The default duration for one full cycle of the indeterminate animation.

This duration is used when the widget creates its own AnimationController because no controller was provided, either directly or through a ProgressIndicatorTheme.

Source

pub fn new() -> LinearProgressIndicator

Creates a linear progress indicator.

The value argument can either be null for an indeterminate progress indicator, or a non-null value between 0.0 and 1.0 for a determinate progress indicator.

Source

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

Dart LinearProgressIndicator(key:).

Source

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

Dart LinearProgressIndicator(backgroundColor:).

Source

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

Dart LinearProgressIndicator(color:).

Source

pub fn value_color( self, value_color: AnimationRef<Option<Color>>, ) -> LinearProgressIndicator

Dart LinearProgressIndicator(valueColor:).

Source

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

Dart LinearProgressIndicator(semanticsLabel:).

Source

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

Dart LinearProgressIndicator(semanticsValue:).

Source

pub fn value(self, value: f64) -> LinearProgressIndicator

Dart LinearProgressIndicator(value:).

Source

pub fn min_height(self, min_height: f64) -> LinearProgressIndicator

Dart LinearProgressIndicator(minHeight:).

Source

pub fn border_radius( self, border_radius: impl Into<BorderRadiusGeometry>, ) -> LinearProgressIndicator

Dart LinearProgressIndicator(borderRadius:).

Source

pub fn stop_indicator_color( self, stop_indicator_color: Color, ) -> LinearProgressIndicator

Dart LinearProgressIndicator(stopIndicatorColor:).

Source

pub fn stop_indicator_radius( self, stop_indicator_radius: f64, ) -> LinearProgressIndicator

Dart LinearProgressIndicator(stopIndicatorRadius:).

Source

pub fn track_gap(self, track_gap: f64) -> LinearProgressIndicator

Dart LinearProgressIndicator(trackGap:).

Source

pub fn year2023(self, year2023: bool) -> LinearProgressIndicator

👎Deprecated:

Set this flag to false to opt into the 2024 progress indicator appearance. Defaults to true. In the future, this flag will default to false. Use ProgressIndicatorThemeData to customize individual properties. This feature was deprecated after v3.26.0-0.1.pre.

Dart LinearProgressIndicator(year2023:).

Source

pub fn controller( self, controller: Ref<AnimationController>, ) -> LinearProgressIndicator

Dart LinearProgressIndicator(controller:).

Trait Implementations§

Source§

impl Clone for LinearProgressIndicator

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LinearProgressIndicator

Source§

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

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

impl Default for LinearProgressIndicator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl ProgressIndicator for LinearProgressIndicator

Source§

impl StatefulWidget for LinearProgressIndicator

Source§

type State = LinearProgressIndicatorState

The state this widget creates.
Source§

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

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 create_state(&self) -> LinearProgressIndicatorState

Creates the mutable state for this widget at a given location in the tree. Read more
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 LinearProgressIndicator

§

impl !Send for LinearProgressIndicator

§

impl !Sync for LinearProgressIndicator

§

impl !UnwindSafe for LinearProgressIndicator

§

impl Forget for LinearProgressIndicator

§

impl Freeze for LinearProgressIndicator
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, NonZero<u32>: Freeze, &'static AnimationVTable<Option<Color>>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<fn() -> AnimationController>: Freeze,

§

impl Move for LinearProgressIndicator

§

impl Unpin for LinearProgressIndicator
where Rc<dyn Key>: Unpin, NonZero<u32>: Unpin, &'static AnimationVTable<Option<Color>>: Unpin, Rc<Keep>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for LinearProgressIndicator
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, &'static AnimationVTable<Option<Color>>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<fn() -> AnimationController>: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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>