-
Notifications
You must be signed in to change notification settings - Fork 219
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
CopyWith to allow setting values to null - like spread operator #40
Comments
This would work but maybe there is a more succinct and descriptive method.
|
Hey there -- yep, in this case, you'd need an extra class like the one you've proposed. You can either create a class just as you've done, or consider using the |
That works a little nicer than my Nullable. I do love the javascript spread operator for this kind of thing though...I wonder if there was a way the Dart team could implement something like this (I'm guessing no due to the typed quality of the lanaguage...it does make my code nice and concise...I still prefer dart to js though!) |
Yah, I really hope they even get "data classes" like Kotlin, which would make this type-safe and easy. Please let me know if I can help further! |
Hi @brianegan , I just stumbled on the same problem and randomly found the solution to why my state isn't updating by randomly reading the copyWith Function. What do you think of if we add a warning or information to the example of flutter_redux where the copyWith Method is shown? It's easier for other people then |
|
Null measurement unit and value after changing the measurement method. This was initially attempted to be implemented by sending two more events when modifying the method, namely the events to null the unit and value, which yielded a very tricky to find bug related to indexing of FoodItems by indexOf(), which was (partially) fixed to indexing by indexWhere() using UUIDs. This needs to be fully fixed in the future.
In the following code, I use the CopyWith pattern. One problem I'm experiencing with this is if I want to set a property to a null value (this is quite easy using the spread operator in js). The value of the name field of the 'Joe' object below is not null, it is 'Bob'. Do you know of any way to overcome this problem in Dart?
The text was updated successfully, but these errors were encountered: