felangel / bloc

A predictable state management library that helps implement the BLoC design pattern
https://bloclibrary.dev
MIT License
11.79k stars 3.39k forks source link

[Question] Authentication flow with pushReplacement in flow #286

Closed fvisticot closed 5 years ago

fvisticot commented 5 years ago

My app is using a bloc for authentication.

  1. Login
  2. Screen with List
  3. ===> PushReplacement to clear the navigation stack
  4. Detail Screen
  5. Logout page with Logout button

When I click on logout:

Unfortunately, the bloc in charge of displaying the login page is no more in the stack (due to PushReplacement) What would be your advice / architecture to fix this issue ?

felangel commented 5 years ago

Hi @fvisticot 👋 Thanks for opening an issue!

Have you taken a look at the basic login example?

I would recommend avoiding PushReplacement for most cases.

Let me know if that helps 👍

fvisticot commented 5 years ago

I do not know how to avoid using PushReplacement. If I only use Push with fullscreenDialog=true I get a cross to close the screen. Is it possible to disable the cross on pushed screens ?

felangel commented 5 years ago

You can just push without fullscreenDialog and then it will be a normal navigation.

fvisticot commented 5 years ago

If I do that, I will have a back arrow to get back :) I try to change the workflow to send an event in the bloc and display a new screen from root tree (like your Login sample)

felangel commented 5 years ago

Yeah it depends on what you want the user experience to be. You can check out the navigation recipe for more details.

Hope that helps 👍