如何检查滑块何时递减并具有何时递减的功能?

How to check when the slider is decrementing and have a function for when it does?

我想在滑块递增时增加 var 的值,在滑块递减时递减该值,我做了 第一部分 但我卡在第二个上了 谁能指出我应该怎么做?

我的滑块代码:

                              child: Slider(
                                value: sliderValue,
                                min: min,
                                max: activityMax,
                                divisions: 4,
                                label: '${sliderValue.round().toString()}',
                                mouseCursor: MouseCursor.uncontrolled,
                                autofocus: true,
                                onChanged: (value) {
                                  setState(
                                    () {
                                      sliderValue = value;
                                      _amountController.text =
                                          sliderValue.toInt().toString();
                                      sizeHeight += 250;
                                    },
                                  );
                                },
                              ),

试试这个:

Slider(
   value: sliderValue,
   min: min,
   max: activityMax,
   divisions: 4,
   label: '${sliderValue.round().toString()}',
   mouseCursor: MouseCursor.uncontrolled,
   autofocus: true,
   onChanged: (value) {
     if(value < sliderValue){
       executeWhenDecrementing();
     }
     setState(
        () {
          sliderValue = value;
          _amountController.text = sliderValue.toInt().toString();
      });
    },
)
void executeWhenDecrementing(){
//Do something
}