-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Number shown is invalid if the range is externally limited #48
Comments
You can use the SpinBox(
value: value,
// ...
canChange: (newValue) {
return newValue <= 3.5 && newValue >= 2.5;
},
onChanged: (newValue) {
setState(() => value = newValue);
},
), |
I did try to use CanChange. However it presents me with another problem, perhaps you can suggest an answer that I am missing. Suppose you have a spinbox with a valid range of 1.5 to 2.5. The user starts typing and enters the single digit 1. My code now gets a callback of both canChange and onChanged. However the value I get is 1, which is not acceptable. If I return false from canChange the edit ends and the user never gets a chance to type ".5". If I return true from canChange the user types .5. Now I get both callbacks again with 1.5 as the value. I can't distingush between "the user is still typing" and "the user is done" How can I prevent the callback until the user presses the done editing checkbox or determine if the user has pressed that or not? Thanks, Don |
Actually I think I might have found an answer. I attach a focus node to the spinbox and then check to see if it has focus in onChanged and ignore the onChanged if it still has the focus. This seems to work. But it seems like it would be better if the spinbox did this or at least provided a different callback. |
The attached code demonstrates a bug with the spinbox. The spinbox itself is limited to a range of 2.0 to 4.0. The value starts at 3.0. However the onChanged callback limits the value to a range of 2.5 to 3.5. If you push the "+" button 6 times, the spinbox will display 3.6 even though the value given to it is limited to 3.5
The text was updated successfully, but these errors were encountered: