pub struct RangeSlider {Show 16 fields
pub key: Option<KeyRef>,
pub values: RangeValues,
pub on_changed: Option<ValueChanged<RangeValues>>,
pub on_change_start: Option<ValueChanged<RangeValues>>,
pub on_change_end: Option<ValueChanged<RangeValues>>,
pub min: f64,
pub max: f64,
pub divisions: Option<i32>,
pub labels: Option<RangeLabels>,
pub active_color: Option<Color>,
pub inactive_color: Option<Color>,
pub overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>,
pub mouse_cursor: Option<WidgetStatePropertyRef<Option<MouseCursorRef>>>,
pub semantic_formatter_callback: Option<SemanticFormatterCallback>,
pub padding: Option<EdgeInsetsGeometry>,
pub year2023: Option<bool>,
}Expand description
A Material Design range slider.
Used to select a range from a range of values.
A range slider can be used to select from either a continuous or a discrete
set of values. The default is to use a continuous range of values from min
to max. To use discrete values, use a non-null value for
divisions, which indicates the number of discrete intervals. For
example, if min is 0.0 and max is 50.0 and
divisions is 5, then the slider can take on the discrete values 0.0,
10.0, 20.0, 30.0, 40.0, and 50.0.
The terms for the parts of a slider are:
- The “thumbs”, which are the shapes that slide horizontally when the user drags them to change the selected range.
- The “track”, which is the horizontal line that the thumbs can be dragged along.
- The “tick marks”, which mark the discrete values of a discrete slider.
- The “overlay”, which is a highlight that’s drawn over a thumb in response to a user tap-down gesture.
- The “value indicators”, which are the shapes that pop up when the user is dragging a thumb to show the value being selected.
- The “active” segment of the slider is the segment between the two thumbs.
- The “inactive” slider segments are the two track intervals outside of the slider’s thumbs.
The range slider will be disabled if on_changed is null or if the
range given by min..max is empty (i.e. if
min is equal to max).
The range slider widget itself does not maintain any state. Instead, when
the state of the slider changes, the widget calls the on_changed
callback. Most widgets that use a range slider will listen for the
on_changed callback and rebuild the slider with new
values to update the visual appearance of the slider. To know when the
value starts to change, or when it is done changing, set the optional callbacks
on_change_start and/or on_change_end.
By default, a slider will be as wide as possible, centered vertically. When given unbounded constraints, it will attempt to make the track 144 pixels wide (including margins on each side) and will shrink-wrap vertically.
Requires one of its ancestors to be a Material widget. This is typically
provided by a Scaffold widget.
Requires one of its ancestors to be a MediaQuery widget. Typically, a
MediaQuery widget is introduced by the MaterialApp or WidgetsApp
widget at the top of your application widget tree.
To determine how it should be displayed (e.g. colors, thumb shape, etc.),
a slider uses the SliderThemeData available from either a SliderTheme
widget, or the ThemeData::slider_theme inside a Theme widget above it in
the widget tree. You can also override some of the colors with the
active_color and inactive_color
properties, although more fine-grained control of the colors, and other visual
properties is achieved using a SliderThemeData.
See also:
SliderThemeandSliderThemeDatafor information about controlling the visual appearance of the slider.Slider, for a single-valued slider.Radio, for selecting among a set of explicit values.CheckboxandSwitch, for toggling a particular value on or off.- https://material.io/design/components/sliders.html
MediaQuery, from which the text scale factor is obtained.
Fields§
§key: Option<KeyRef>§values: RangeValuesThe currently selected values for this range slider.
The slider’s thumbs are drawn at horizontal positions that corresponds to these values.
on_changed: Option<ValueChanged<RangeValues>>Called when the user is selecting a new value for the slider by dragging.
The slider passes the new values to the callback but does not actually change state until the parent widget rebuilds the slider with the new values.
If null, the slider will be displayed as disabled.
The callback provided to on_changed should update the state of the
parent StatefulWidget using the State::set_state method, so that the parent gets
rebuilt.
See also:
on_change_start, which is called when the user starts changing the values.on_change_end, which is called when the user stops changing the values.
on_change_start: Option<ValueChanged<RangeValues>>Called when the user starts selecting new values for the slider.
This callback shouldn’t be used to update the slider values (use
on_changed for that). Rather, it should be used to be notified when
the user has started selecting a new value by starting a drag or with a tap.
The values passed will be the last values that the slider had before
the change began.
See also:
on_change_endfor a callback that is called when the value change is complete.
on_change_end: Option<ValueChanged<RangeValues>>Called when the user is done selecting new values for the slider.
This differs from on_changed because it is only called once at the
end of the interaction, while on_changed is called as the value is
getting updated within the interaction.
This callback shouldn’t be used to update the slider values (use
on_changed for that). Rather, it should be used to know when the
user has completed selecting a new values by ending a drag or a click.
See also:
on_change_startfor a callback that is called when a value change begins.
min: f64The minimum value the user can select.
Defaults to 0.0. Must be less than or equal to max.
If the max is equal to the min, then the slider is
disabled.
max: f64The maximum value the user can select.
Defaults to 1.0. Must be greater than or equal to min.
If the max is equal to the min, then the slider is
disabled.
divisions: Option<i32>The number of discrete divisions.
Typically used with labels to show the current discrete values.
If null, the slider is continuous.
labels: Option<RangeLabels>Labels to show as text in the SliderThemeData::range_value_indicator_shape
when the slider is active and SliderThemeData::show_value_indicator
is satisfied.
There are two labels: one for the start thumb and one for the end thumb.
Each label is rendered using the active ThemeData’s TextTheme::body_large text
style, with the theme data’s ColorScheme::on_primary color. The label’s text style
can be overridden with SliderThemeData::value_indicator_text_style.
If null, then the value indicator will not be displayed.
See also:
RangeSliderValueIndicatorShapefor how to create a custom value indicator shape.
active_color: Option<Color>The color of the track’s active segment, i.e. the span of track between the thumbs.
Defaults to ColorScheme::primary of the ambient ThemeData.
Using a SliderTheme gives more fine-grained control over the appearance of various
components of the slider.
inactive_color: Option<Color>The color of the track’s inactive segments, i.e. the span of tracks between the min and the start thumb, and the end thumb and the max.
Defaults to ColorScheme::primary with 24% opacity of the ambient ThemeData.
Using a SliderTheme gives more fine-grained control over the appearance of various
components of the slider.
overlay_color: Option<WidgetStatePropertyRef<Option<Color>>>The highlight color that’s typically used to indicate that
the range slider thumb is in WidgetState::Hovered or WidgetState::Dragged
states.
If this property is null, RangeSlider will use active_color
with an opacity of 0.12, SliderThemeData::overlay_color, or the default value of
ColorScheme::primary with an opacity of 0.12.
mouse_cursor: Option<WidgetStatePropertyRef<Option<MouseCursorRef>>>The cursor for a mouse pointer when it enters or is hovering over the widget.
If null, then the value of SliderThemeData::mouse_cursor is used. If that is also
null, then WidgetStateMouseCursor::clickable is used.
See also:
WidgetStateMouseCursor, which can be used to create aMouseCursorthat is also aWidgetStateProperty<MouseCursor>.
semantic_formatter_callback: Option<SemanticFormatterCallback>The callback used to create a semantic value from the slider’s values.
Defaults to formatting values as a percentage.
Waits with accessibility: the callback is held and not called.
padding: Option<EdgeInsetsGeometry>The padding between the slider and the edge of its bounds.
If it is null, the value of SliderThemeData::padding is used. If that is also null,
the default padding is the same as the thumb overlay, which is 24 on each side.
year2023: Option<bool>When true, the RangeSlider will use the 2023 Material Design appearance.
If not set, then the RangeSlider will behave as if this is set to true, or
the value of SliderThemeData::year2023.
If this is set to false, the RangeSlider will use the latest Material Design
appearance, which was introduced in December 2023.
Defaults to true.
Implementations§
Source§impl RangeSlider
impl RangeSlider
Sourcepub fn new(
values: RangeValues,
on_changed: Option<ValueChanged<RangeValues>>,
) -> RangeSlider
pub fn new( values: RangeValues, on_changed: Option<ValueChanged<RangeValues>>, ) -> RangeSlider
Creates a Material Design range slider.
The range slider widget itself does not maintain any state. Instead, when
the state of the slider changes, the widget calls the on_changed
callback. Most widgets that use a range slider will listen for the
on_changed callback and rebuild the slider with new
values to update the visual appearance of the slider. To know when the
value starts to change, or when it is done changing, set the optional callbacks
on_change_start and/or on_change_end.
values, which determines currently selected values for this range slider.on_changed, which is called while the user is selecting a new value for the range slider.on_change_start, which is called when the user starts to select a new value for the range slider.on_change_end, which is called when the user is done selecting a new value for the range slider.
You can override some of the colors with the active_color and
inactive_color properties, although more fine-grained control
of the appearance is achieved using a SliderThemeData.
The min must be less than or equal to the max.
The RangeValues::start attribute of the values parameter must be
less than or equal to its RangeValues::end attribute. The RangeValues::start
and RangeValues::end attributes of the values parameter must be
greater than or equal to the min parameter and less than or equal to
the max parameter.
The divisions parameter must be null or greater than zero.
Sourcepub fn key(self, key: KeyRef) -> RangeSlider
pub fn key(self, key: KeyRef) -> RangeSlider
Dart RangeSlider(key:).
Sourcepub fn on_change_start(
self,
on_change_start: impl Fn(&mut App, RangeValues) + 'static,
) -> RangeSlider
pub fn on_change_start( self, on_change_start: impl Fn(&mut App, RangeValues) + 'static, ) -> RangeSlider
Dart RangeSlider(onChangeStart:).
Sourcepub fn on_change_end(
self,
on_change_end: impl Fn(&mut App, RangeValues) + 'static,
) -> RangeSlider
pub fn on_change_end( self, on_change_end: impl Fn(&mut App, RangeValues) + 'static, ) -> RangeSlider
Dart RangeSlider(onChangeEnd:).
Sourcepub fn min(self, min: f64) -> RangeSlider
pub fn min(self, min: f64) -> RangeSlider
Dart RangeSlider(min:).
Sourcepub fn max(self, max: f64) -> RangeSlider
pub fn max(self, max: f64) -> RangeSlider
Dart RangeSlider(max:).
Sourcepub fn divisions(self, divisions: i32) -> RangeSlider
pub fn divisions(self, divisions: i32) -> RangeSlider
Dart RangeSlider(divisions:).
Sourcepub fn labels(self, labels: RangeLabels) -> RangeSlider
pub fn labels(self, labels: RangeLabels) -> RangeSlider
Dart RangeSlider(labels:).
Sourcepub fn active_color(self, active_color: Color) -> RangeSlider
pub fn active_color(self, active_color: Color) -> RangeSlider
Dart RangeSlider(activeColor:).
Sourcepub fn inactive_color(self, inactive_color: Color) -> RangeSlider
pub fn inactive_color(self, inactive_color: Color) -> RangeSlider
Dart RangeSlider(inactiveColor:).
Sourcepub fn overlay_color(
self,
overlay_color: WidgetStatePropertyRef<Option<Color>>,
) -> RangeSlider
pub fn overlay_color( self, overlay_color: WidgetStatePropertyRef<Option<Color>>, ) -> RangeSlider
Dart RangeSlider(overlayColor:).
Sourcepub fn mouse_cursor(
self,
mouse_cursor: WidgetStatePropertyRef<Option<MouseCursorRef>>,
) -> RangeSlider
pub fn mouse_cursor( self, mouse_cursor: WidgetStatePropertyRef<Option<MouseCursorRef>>, ) -> RangeSlider
Dart RangeSlider(mouseCursor:).
Sourcepub fn semantic_formatter_callback(
self,
semantic_formatter_callback: SemanticFormatterCallback,
) -> RangeSlider
pub fn semantic_formatter_callback( self, semantic_formatter_callback: SemanticFormatterCallback, ) -> RangeSlider
Dart RangeSlider(semanticFormatterCallback:).
Sourcepub fn padding(self, padding: impl Into<EdgeInsetsGeometry>) -> RangeSlider
pub fn padding(self, padding: impl Into<EdgeInsetsGeometry>) -> RangeSlider
Dart RangeSlider(padding:).
Sourcepub fn year2023(self, year2023: bool) -> RangeSlider
👎Deprecated: Set this flag to false to opt into the 2024 range slider appearance. Defaults to true. In the future, this flag will default to false. Use SliderThemeData to customize individual properties. This feature was deprecated after v3.30.0-0.1.pre.
pub fn year2023(self, year2023: bool) -> RangeSlider
Set this flag to false to opt into the 2024 range slider appearance. Defaults to true. In the future, this flag will default to false. Use SliderThemeData to customize individual properties. This feature was deprecated after v3.30.0-0.1.pre.
Dart RangeSlider(year2023:).
Trait Implementations§
Source§impl Clone for RangeSlider
impl Clone for RangeSlider
Source§impl Debug for RangeSlider
impl Debug for RangeSlider
Source§impl StatefulWidget for RangeSlider
impl StatefulWidget for RangeSlider
Source§type State = RangeSliderState
type State = RangeSliderState
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 create_state(&self) -> RangeSliderState
fn create_state(&self) -> RangeSliderState
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 RangeSlider
impl !Send for RangeSlider
impl !Sync for RangeSlider
impl !UnwindSafe for RangeSlider
impl Forget for RangeSlider
impl Freeze for RangeSliderwhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const RcInner<dyn Fn(&mut App, RangeValues)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, RangeValues)>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: Freeze,
PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: Freeze,
*const RcInner<dyn WidgetStateProperty<Option<Rc<dyn MouseCursor>>>> is !null: Freeze,
PhantomData<RcInner<dyn WidgetStateProperty<Option<Rc<dyn MouseCursor>>>>>: Freeze,
*const RcInner<dyn Fn(f64) -> String> is !null: Freeze,
PhantomData<RcInner<dyn Fn(f64) -> String>>: Freeze,
impl Move for RangeSlider
impl Unpin for RangeSlider
impl UnsafeUnpin for RangeSliderwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, RangeValues)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, RangeValues)>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const RcInner<dyn WidgetStateProperty<Option<Color>>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn WidgetStateProperty<Option<Color>>>>: UnsafeUnpin,
*const RcInner<dyn WidgetStateProperty<Option<Rc<dyn MouseCursor>>>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn WidgetStateProperty<Option<Rc<dyn MouseCursor>>>>>: UnsafeUnpin,
*const RcInner<dyn Fn(f64) -> String> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(f64) -> String>>: 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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.