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
I have searched on google with this:
"back button" site:bloclibrary.dev
(and have also searched that site/domain for "navigate back" , "back navigation", "backwards navigation", "navigate backwards" and "arrow" as in back arrow)
but could not find anything there in the official pages about how to implement back button navigation.
I have learned the basics about bloc regarding how you navigate forward (so to speak) by letting the bloc implementation call the emit method, which will then trigger a new page that can become rendered with a BlocBuilder.
But I just do not understand how you should implement navigation backwards.
When you use Flutter without bloc you would use Navigator.push to move forward and then Navigator.pop to go back.
As far as I understand, the bloc internal code does not use Navigator.push, so therefore I can not expect to be able to use Navigator.pop to go back?
There should hopefully be a simple way of implementing back navigation?
If so, then please document it.
One way of doing it that I can figure out seems more complicated than it should have to be:
I could use the Command pattern in every bloc and save any new event into a Command object and put in on a stack of command objects.
And then try to capture all back button events (and back arrow clicks) and then find the previous command on the stack, and let the "command.undo" implemetnation method send the previous event to the block again with the method context.read<T>.add(event)
But I guess there should be some much simpler way of support back navgiation?
How? Is there any example project showing how to navigate backwards in a simple way when using bloc?
The text was updated successfully, but these errors were encountered:
The Bloc library is excellent for managing the state within individual views. However, if you require state management during navigation, it's better to use dedicated navigation packages like go_router. go_router is designed to manage navigation state more naturally and provide support for the newer routing system known as Navigator 2.0. Alternatively, if you don't need such a complex routing system, you can use the flow_builder package, which follows a design similar to Bloc.
Description
I have searched on google with this:
"back button" site:bloclibrary.dev
(and have also searched that site/domain for "navigate back" , "back navigation", "backwards navigation", "navigate backwards" and "arrow" as in back arrow)
but could not find anything there in the official pages about how to implement back button navigation.
I have learned the basics about bloc regarding how you navigate forward (so to speak) by letting the bloc implementation call the emit method, which will then trigger a new page that can become rendered with a BlocBuilder.
But I just do not understand how you should implement navigation backwards.
When you use Flutter without bloc you would use Navigator.push to move forward and then Navigator.pop to go back.
As far as I understand, the bloc internal code does not use Navigator.push, so therefore I can not expect to be able to use Navigator.pop to go back?
There should hopefully be a simple way of implementing back navigation?
If so, then please document it.
One way of doing it that I can figure out seems more complicated than it should have to be:
I could use the Command pattern in every bloc and save any new event into a Command object and put in on a stack of command objects.
And then try to capture all back button events (and back arrow clicks) and then find the previous command on the stack, and let the "command.undo" implemetnation method send the previous event to the block again with the method context.read<T>.add(event)
But I guess there should be some much simpler way of support back navgiation?
How?
Is there any example project showing how to navigate backwards in a simple way when using bloc?
The text was updated successfully, but these errors were encountered: