ReplayCubit - List with mutated state can not be redo / undo #60
Comments
Hi @md-weber 👋 Are you able to provide a link to a sample app which I can run to reproduce the issue? Thanks 🙏 |
Maybe this is related, so I'm going to add it here and let me know if I need to open a new issue. Cubit is not saving the state after emit(). If I get something please let me know: In the following example I expect the last print to print "State: 3" but it prints: "State: 0". import 'package:cubit/cubit.dart';
void main() async {
final cubit = CounterCubit();
cubit.increment();
}
class CounterCubit extends Cubit<int> {
CounterCubit() : super(0);
void increment() async {
emit(state + 1);
print('State: $state');
emit(state + 1);
print('State: $state');
//await Future.delayed(Duration(milliseconds: 500));
emit(state + 1);
print('State: $state');
}
} The output is:
Now if I run the same code but with the Future uncomented then the last print shows "State: 1" and the complete output is:
@felangel I can show my flutter code where my CubitBuilder is not being rebuilt in some cases when I run a |
@pedromassango can you please try the above code using I just tested and the above code outputs
when using v0.2.0-dev.1 👍 |
It is working on this version thanks. When we can espect this to be released? |
@pedromassango I'm working on a few other breaking changes currently but should have a stable 0.2.0 out sometime this week 👍 Feel free to use |
This just saved my day. Thanks. |
@felangel I added an own branch in one of my projects that includes the problem. You can run the app, select a drink and click the action icons to undo it. https://github.com/md-weber/state_tutorials/tree/minimal_example |
Thanks @md-weber! I’ll have a look shortly 👍 |
@md-weber just took a look and opened a pull request with the fix. The reason the Hope that helps 👍 |
Fantastic thanks for that, now I feel quite stupid 😄. Ok, I understand now, thanks and keep up the great work :) |
@md-weber no worries at all it's a subtle detail haha. Keep up the awesome work on your Youtube channel! 🎉 |
Describe the bug
If I execute redo/undo on a state that has been spread into a new list it seems that I cannot redo/undo the state.
To Reproduce
Create a cubit with a List of elements and change the values of the list. After that spread, the list into the emit of the cubit. The CubitBuilder gets retriggered but with the old state.
Expected behavior
The redo and undo function should work properly and update the state for the List.
**Logs **
The text was updated successfully, but these errors were encountered: