0

I have a project that I had initially setup with Navigator and have since converted over to use BLoC Cubit.

When I use Navigator.of(context).pop(); to go back from a screen that was navigated to using context.read<AppCubits>().pageOneScreen(); I get a black screen instead of being directed back.

Does BloC Cubit's not allow or keep any history like Navigator does?

**** MORE DETAILS ****

I have a back button that would simply call

Navigator.of(context).pop()

and bring the user back to their previous page.

Now with Cubit, using the above doesn't work and returns a blank screen as there is no context stored.

So I have been searching for a solution to this but every one of them seems very verbose, is this type of feature not a part of Cubit or BLoC?

To navigate from page to page currently I am using

context.read<AppCubits>().pageOneScreen();

context.read<AppCubits>().pageTwoScreen();

This works as expected but I am looking for a solution to adding a call that will navigate back to the previous screen/state that was loaded. So if I was on pageTwoScreen, I could click back if I had come from pageOneScreen and have the state changed or at least be directed back to pageOneScreen.

Do I have to create a list and store the state value as a form of rudimentary history and then pop off the previous value and call something akin to

context.read<AppCubits>().historylistvalue()

VanCoon
  • 422
  • 4
  • 20

0 Answers0