sleek_circular_slider icon indicating copy to clipboard operation
sleek_circular_slider copied to clipboard

Detect if value change come from user

Open RegisSaffi opened this issue 5 years ago • 4 comments

Thanks for this widget,it is really awesome and customizable, but i am wondering if i want to set a value dynamically how would i do it? well, i can set the initial value and i can update it, but if i want to use both user interaction change and dynamic value change i can't do it, if you can add where i can know if the value change is coming from the user interaction or not, it could be useful in many cases.

RegisSaffi avatar May 01 '20 19:05 RegisSaffi

Hmm... I will think about it. Currently very busy...

matthewfx avatar May 11 '20 09:05 matthewfx

Lets assume you have some source where you can get the value when change came not from user. Let it be:

MyDataStorage

With above in mind:

bool _changedHere = false;
double _value = 0;

Widget build(BuildContext context) {
if (!_changedHere) {
  _value = MyDataStorage.getValue(); //Data NOT from user
} else {
  _changedHere == false; //Change was done by user, so we'll not change the value, but only during current widget build
}
return SleekCircularSlider(
  min: 0,
  max: 255,
  initialValue: _value,
  onChangeEnd: (val) {
    setState((){
      _changedHere = true;
      _value = val;
    });
  }
);
}

I don't think this should be done in plugin itself.

estevez-dev avatar May 21 '20 12:05 estevez-dev

Also if you have animations enabled and see a tearing, create one CircularSliderAppearance and then reuse it, don´t create it on every build.

spixy avatar Aug 23 '21 14:08 spixy

Also if you have animations enabled and see a tearing, create one CircularSliderAppearance and then reuse it, don´t create it on every build.

This should be in the docs, the tearing drove me crazy for weeks, I was able to solve it by hacking setStates around the place, but your comment solves everything. Many many thanks @spixy !

surister avatar Sep 13 '21 10:09 surister