Ad

How To Prevent User From Being Able To Slide Left Thumb In Flutter RangeSilder

- 1 answer

This is my range slider widget implementation, I want to prevent the user from being able to slide the left thumb slider

  RangeSlider(
                          divisions: 5,
                          activeColor: Colors.red[700],
                          inactiveColor: Colors.grey,
                          min: 1.0,
                          max: 10.0,
                          values: values,
                          labels: labels,
                          onChanged: (value) {
                            state(
                              () {
                                values = value;
                                labels = RangeLabels(
                                  "${value.start.toInt().toString()}km",
                                  "${value.end.toInt().toString()}km",
                                );
                              },
                            );
                          },
                        ),
Ad

Answer

Add if (values.start != value.start) return; inside your onChanged, this will prevent updating values which prevent updating the RangeSlider

Ad
source: stackoverflow.com
Ad