I have a bloc which initially sees mapEventToState being called at app startup but shortly afterwards stops receiving events. onEvent continues to be called however, and my other blocs do not exhibit this behaviour as far as I can tell. Any ideas why this would happen? close() is not being called.
Question: are you always emitting the same state? If you emitted the same state twice mapEventToState won't be called for the second state.
Are you using equatable?
Closing for now but feel free to comment with additional information and I'm happy to continue the conversation 馃憤
having the same issue
I have a different class for every state and emitting a different state as well.
But still, Bloc's onEvent is called but mapEventToState is not.
please help
having the same issue
I have a different class for every state and emitting a different state as well.
But still, Bloc's onEvent is called but mapEventToState is not.please help
Could you please share your code?
having the same issue
I have a different class for every state and emitting a different state as well.
But still, Bloc's onEvent is called but mapEventToState is not.
please helpCould you please share your code?
https://gist.github.com/tapanrgohil/b8a942c444476ba0ced2ab43242cd7d1
here is my code for page and bloc
now after few modifications in the code
InitialLoginState, LoadingState and OtpsentState works fine
but when I call VerifyOtpEvent event application do not responds for few second and certainly every works fine. earier it was not responding at all
I am very new at flutter so may be my code is not upto mark.
Hi 馃憢
Thanks for your code mate!
I realized you used Equatable package but you didn't pass the variable into the prop getter.
For example:
`
class SendOtpEvent extends LoginEvent {
String phoNo;
SendOtpEvent({this.phoNo});
}
`
you will need to pass phoNo variable to the prop getter, like this:
`
class SendOtpEvent extends LoginEvent {
String phoNo;
SendOtpEvent({this.phoNo});
}
@override
List
The reason for waiting few seconds it's mostly because you used async/ await, so it will wait the process finishing before doing something else.
The reason for waiting few seconds it's mostly because you used async/ await, so it will wait the process finishing before doing something else.
can you help on this? because firebase phoneAuthentication required such callback functions and unable to complete awaiting task.
I can look closely into the code tomorrow as it's already 2 in the night in my area.
talk soon!
@tapanrgohil I would recommend just adding another event to the bloc from the callback functions. Check out https://github.com/felangel/bloc/blob/2076b2661aac15e2cbf52dd52d3e5c31a1a6c41d/examples/flutter_bloc_with_stream/lib/bloc/ticker_bloc.dart#L19 as an example. In your case rather than listening to a stream you would just add events in from the callback functions.
Hope that helps 馃憤
Hi, sorry for late reply, I think you should put loading state outside of try catch block:
in loginBloc line 30.
Also consider what Felix mentioned adding event through callback.
hope it can solve your problem.
Hi, sorry for late reply, I think you should put loading state outside of try catch block:
in loginBloc line 30.
Also consider what Felix mentioned adding event through callback.
hope it can solve your problem.
Hi
thanks for the reply I applied code as you suggest.
But still, it is not working
when I emits VerifyOtpEvent it waits for few second and directly emits the LoginCompleteState or OtpExceptionState , LoadingState is never yield.
But on next time when I emit VerifyOtpEvent again, it works perfectly fine.
@tapanrgohil I would recommend just adding another event to the bloc from the callback functions. Check out
as an example. In your case rather than listening to a stream you would just add events in from the callback functions.
Hope that helps 馃憤
I did as you suggested add event from callback function worked well
@felangel and @jakecastelli
Thanks so much for time and help.
Most helpful comment
Question: are you always emitting the same state? If you emitted the same state twice mapEventToState won't be called for the second state.
Are you using equatable?