flutter_xlider icon indicating copy to clipboard operation
flutter_xlider copied to clipboard

On drag one value keeps falsely showing up as selected

Open ehaberkorn opened this issue 4 years ago • 4 comments

If I set the percent inside on FlutterSliderFixedValue to 3 and the value to 6, the 6 keeps showing up as selected even if it is not. When I leave the 3 out as percent everything works as expected. Please refer to the code snippet below.

FlutterSlider(
                              trackBar: FlutterSliderTrackBar(
                                activeTrackBar: BoxDecoration(
                                    color: AppColors.DARK_BLUE_FF085651),
                              ),
                              tooltip: null,
                              handler: FlutterSliderHandler(
                                  child: Container(),
                                  decoration: BoxDecoration(
                                      boxShadow: [
                                        BoxShadow(
                                            color: Colors.black26,
                                            blurRadius: 2,
                                            spreadRadius: 0.2,
                                            offset: Offset(0, 1))
                                      ],
                                      color: Colors.white,
                                      shape: BoxShape.circle)),
                              values: [
                                3,
                                4,
                                5,
                                6,
                                7.5,
                                10,
                                15,
                                20,
                                30,
                                40,
                                50,
                                75,
                                100,
                                150,
                                200
                              ],
                              min: 3,
                              max: 200,
                              onDragging: (index, newValue, upperValue) {
                                setState(() {
                                  _sliderValue = newValue.toDouble();
                                });
                              },
                              jump: true,
                              fixedValues: [
                                FlutterSliderFixedValue(percent: 0, value: 3),
                                FlutterSliderFixedValue(percent: 1, value: 4),
                                FlutterSliderFixedValue(percent: 2, value: 5),
                                FlutterSliderFixedValue(percent: 3, value: 6),    //this is causing the behavior
                                FlutterSliderFixedValue(percent: 4, value: 7.5),
                                FlutterSliderFixedValue(percent: 5, value: 10),
                                FlutterSliderFixedValue(percent: 7, value: 15),
                                FlutterSliderFixedValue(percent: 10, value: 20),
                                FlutterSliderFixedValue(percent: 15, value: 30),
                                FlutterSliderFixedValue(percent: 20, value: 40),
                                FlutterSliderFixedValue(percent: 25, value: 50),
                                FlutterSliderFixedValue(percent: 37, value: 75),
                                FlutterSliderFixedValue(
                                    percent: 50, value: 100),
                                FlutterSliderFixedValue(
                                    percent: 75, value: 150),
                                FlutterSliderFixedValue(
                                    percent: 100, value: 200)
                              ],
                              step: FlutterSliderStep(
                                step: 1, // default
                                isPercentRange: false,
                              ),
                            )

ehaberkorn avatar Feb 25 '21 10:02 ehaberkorn

Hello. sorry for my late response. This is a bug and is fixed in the upcoming version.
The cause of the bug is setState which sets state to initial value. and your initial value in values array is 3, so the fixed value for 3 is 6
Also the way you use values is not correct. values array only accepts two number, one for lower and one for upper values.
the next version will be ready in the next couple days

Ali-Azmoud avatar Mar 05 '21 13:03 Ali-Azmoud

Hi, thanks for the info. I have fixed my values to only two. Also I found out that, if any of the other widgets I use in my view calls setState() the slider gets reset. I guess that this will be fixed with the next version because it is related to this issue.

ehaberkorn avatar Mar 11 '21 11:03 ehaberkorn

@Ali-Azmoud is there any progress? Sorry for the pressure, but I need this urgently...

ehaberkorn avatar Mar 19 '21 09:03 ehaberkorn

still not fixed?

arslan9380 avatar Mar 27 '21 10:03 arslan9380