Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for code review @AhmedLSayed9 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For example, I want to update the state only if there's no problem with the new state using an 'if' statement, and if there's a problem, I don't want to update the status but provide the previous one.
I've tried to simplify a problem from my project.
The program below takes two String values via textEditingController, converts them to doubles, and displays their multiplied result. If there's an issue with the text input via the textEditingController, it displays the reason for the error and sets the result value arbitrarily to -11111. An example of such an error would be when the input is like "10.", ending with a period, leading to a parsing error.
I want to display the previously calculated value instead of a number like -11111 when there's an error. For example, if the previous calculation was 10 x 20 = 200, and the input changes to 10. x 20, I'd like to show 200 instead of -11111.
I thought simply returning the state would suffice, but I encountered an "uninitialized provider error."
Any idea?
Should i use a different approach?
I'm a beginner with Riverpod, and while I'm seeking answers to my questions, I also welcome any refactoring suggestions.
Beta Was this translation helpful? Give feedback.
All reactions