Skip to main content

Slider Label Position & Slider Notifier Documentation

Overview

The SliderLabelPosition enum and SliderNotifier class provide functionality for customizing label placement on sliders and managing slider state changes efficiently using ChangeNotifier.

SliderLabelPosition

Defines the available positions for slider labels.

Enum Values

  • side: Displays labels at the left and right sides of the slider.
  • bottom: Displays labels below the slider.
  • none: Hides the labels.

Usage Example

CwSingleSlider(
minValue: 0,
maxValue: 100,
currentFirstValue: 50,
sliderLabelPosition: SliderLabelPosition.bottom,
onChange: (value) {},
)

SliderNotifier

A ChangeNotifier class that manages the state of single and range sliders.

Properties

  • currFirstValue: Stores the current value of a single slider or the first value of a range slider.
  • currSecondValue: Stores the second value of a range slider.

Methods

changeValue(double value)

  • Updates currFirstValue for a single slider and notifies listeners.

changeRangeValue(double firstValue, double secondValue)

  • Updates currFirstValue and currSecondValue for a range slider and notifies listeners.

Usage Example

final sliderNotifier = SliderNotifier();

// Updating a single slider
sliderNotifier.changeValue(40.0);

// Updating a range slider
sliderNotifier.changeRangeValue(20.0, 80.0);

Customization Options

  • The SliderLabelPosition enum allows dynamic positioning of slider labels.
  • SliderNotifier simplifies state management by providing real-time updates to UI components.

Source Code Repository

Find the full source code on GitHub: GitHub Repository