interval property

double? interval
final

Splits the slider into given interval. It is mandatory if labels, major ticks and dividers are needed.

For example, if min is 0.0 and max is 10.0 and interval is 2.0, the slider will render the labels, major ticks, and dividers at 0.0, 2.0, 4.0 and so on.

For date value, the slider doesn’t have auto interval support. So, you may need to set interval, dateIntervalType, and dateFormat for date value, if labels, ticks, and dividers are needed.

For example, if min is DateTime(2000, 01, 01, 00) and max is DateTime(2005, 12, 31, 24), interval is 1.0, dateFormat is DateFormat.y(), and dateIntervalType is DateIntervalType.years, then the slider will render the labels, major ticks, and dividers at 2000, 2001, 2002 and so on.

Defaults to null. Must be greater than 0.

This snippet shows how to set numeric interval in SfSlider.

double _value = 4.0;

SfSlider(
  min: 0.0,
  max: 10.0,
  value: _value,
  interval: 2,
  showTicks: true,
  showLabels: true,
  onChanged: (dynamic newValue) {
    setState(() {
      _value = newValue;
    });
   },
)

This snippet shows how to set date interval in SfSlider.

DateTime _value = DateTime(2002, 01, 01);

SfSlider(
  min: DateTime(2000, 01, 01, 00),
  max: DateTime(2005, 12, 31, 24),
  value: _value,
  interval: 1,
  showTicks: true,
  showLabels: true,
  dateFormat: DateFormat.y(),
  dateIntervalType: DateIntervalType.years,
  onChanged: (dynamic newValue) {
    setState(() {
     _value = newValue;
    });
  },
)

See also:

Implementation

final double? interval;