I am getting "'AuthenticationBloc.mapEventToState' ('(AuthenticationState, AuthenticationEvent) → Stream
How am I meant to get the currentState now?
@QoLTech what examples are you referring to? Everything should be updated to use the latest version bloc.
currentState is a property that you can access on all blocs.
For example, here. You removed the currentState from the method signature, but continue to use it in the method body.
You're saying that you can get currentState now without including it in the signature?
Okay, so I can access currentState without it needing to be in the signature.
However, I now have this issue and I'm not sure if it's related.
In my mapEventToState method, I could do this:
if (currentState is DocumentSuccessful) {
yield DocumentSuccessful(document: currentState.document);
}
I now have to do this:
if (currentState is DocumentSuccessful) {
yield DocumentSuccessful(document: (currentState as DocumentSuccessful).document);
}
After checking the type of currentState, it allowed me to continue using currentState as if it was the DocumentSuccessful type which has the document property on it. I can no longer do so and I have to manually use 'as'. Do you know why this is?
@QoLTech the currentState in the method body is the bloc property. That's how it should be in v0.11.0 of bloc.
The error you're running into is because currentState is a computed property. You can do something like:
final _currentState = currentState;
if (_currentState is DocumentSuccessful) {
yield DocumentSuccessful(document: _currentState.document);
}
Hope that helps 👍
Works great, thank you!
Most helpful comment
Works great, thank you!