You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
The Bloc listener is not listening for changes from the Authentication cubit but the Bloc builder got a new state and updated the UI based on the new state emitted from the cubit.
Steps To Reproduce
Authentication cubit is set first with the init function that emits a new state based on the user ID, we store the user ID while logging, if the user ID is null, navigate to the login screen, if the user ID is not null, navigate to the home page.
Gave bloc provider in the main function of my app class, and in my app class we defined the route in on generate route and home with the class in which we use bloc listener and bloc builder
Bloc Builder got the state and it shows the UI based on the state, but the Bloc listener doesn't.
Expected Behavior
I need to navigate to the home page if the user ID is not null, else I need to navigate to the login screen.
Screenshots
kindly check the below screenshots
The text was updated successfully, but these errors were encountered:
It's hard to judge since you didn't show what is on the first screenshot and when in the widget tree you are using it. But my guess would be that you are expecting the widget with BlocListener and BlocBuilder (you can combine them using BlocConsumer btw) to work with the latest state of that bloc/cubit. But that is only true for the BlocBuilder, not for BlocListener. BlocListener works only with state changes, aka you must have the widget attached before the state changes to trigger the listener.
Description
The Bloc listener is not listening for changes from the Authentication cubit but the Bloc builder got a new state and updated the UI based on the new state emitted from the cubit.
Steps To Reproduce
Expected Behavior
I need to navigate to the home page if the user ID is not null, else I need to navigate to the login screen.
Screenshots
kindly check the below screenshots
The text was updated successfully, but these errors were encountered: