pmatatias / input-quantity

Flutter widget for input quantity item
https://pub.dev/packages/input_quantity
MIT License
12 stars 13 forks source link

onQtyChanged and longpress only when longrpess ends #62

Open BearAndBunny opened 4 weeks ago

BearAndBunny commented 4 weeks ago

Is it possible to add an option, so that onQtyChanged is called only when a lonpress ends, instead of being called continuously? The reason is that I want to change the qantity in a Cubit that triggers a reapaint of widgets and also set the value in a database table. For this, I'm only interested in the final quantity value, when the user stops increasing the value.

pmatatias commented 3 weeks ago

thank you for using this package. I understand your need. is it possible to handle it from your cubit?

I have less experiance with bloc state management. as per my knowledge , we can control when the widget rebuild. for example, call setState means we need to rebuild.

this is update the value but not rebuild the widget

void updateVal (int newVal) {
  myVal = newVal
}

this is update value, and rebuild widget with new value

void updateVal (int newVal) {
  setState((){
       myVal = newVal
  })
}

same like notifyListeners() . when you call this in you function, this will rebuild related component in your UI.