Josh Beck
Josh Beck

Reputation: 1

Flutter | Persisting Navigator State Using Hydrated Bloc with the Bloc Design Pattern

Currently, I am working on a mobile app developed in Flutter and Dart that uses Bloc as its design pattern. It is a multiple-page app with various navigation scenarios including a conditional launch screen that is directly returned as a parameter to the MaterialApp's home field.

My end goal is that even after the app closes out or memory issue, the app will return to the page that it left off on.

I am unsure how to store the Navigator's "value" as it is persisted outside of Bloc. I've attempted to use a mixture of the Restoration Manager and hydrated_bloc but am having trouble restoring the Navigator because of the Bloc design implementation causing conditional page navigation (still through Navigator) in the app.

FWIW, currently I am not using named routes for the Navigator but passing parameterized initializers for various Stateless widget pages.

Is there a way to store and restore the Navigator in Flutter through hydrated_bloc?

I've attempted to use the default Restoration Manager in Flutter. However, as the project uses Bloc as its state management, I have been trying to use the hydrated_bloc package to restore the state. This has worked pretty well for restoring values stored in the state but has not worked to restore the Navigator (which means the last page the user is on is always cleared).

Upvotes: 0

Views: 80

Answers (0)

Related Questions