Closed simonckenyon closed 3 years ago
This is not related to AsyncRedux, but it's a Dart requirement: If you mark a class as @immutable then all members should be final. So, yes, the instance variables should be set in the constructor.
Redux also works with "effectively immutable" classes, which means classes that you promise not to modify after creation. However, this is dangerous. You may end up modifying them unintentionally.
A question: Why do you think it's bad having to provide the object data in the constructor? That's usually a good thing. Can you give me more information on what you are trying to do?
I have annotated the AppState
of all examples with @immutable
. I am going to close this. Please let me know if you still have any questions.
Also, if you have any trouble creating an immutable state because of having to provide the object data in the constructor, please show me here the code you're having problems with, and I will give you options. Thanks.
The example in the documentation was written before the move to null safety.
Would it be possible to update it?
My issue is that I had marked my State class as @immutable. This caused a warning saying that the members were not final. Making them final means that the instance variables have to be required in the constructor.
Is this the way to go?