slovnicki / beamer

A routing package built on top of Router and Navigator's pages API, supporting arbitrary nested navigation, guards and more.
MIT License
582 stars 128 forks source link

Last widget/page is being rebuilt when navigating to different beam location, which results in errors #661

Closed Sten435 closed 1 month ago

Sten435 commented 3 months ago

Describe the bug When navigation to a different beam location, the current page you are on (the location where you are navigating away from) is re-build 1 more time.

Since I put my Bloc Providers in each beam location and I navigate to location B from location A and the current page of location A is rebuilt right before navigating (for some reason this happens). I get a (bloc) provider not found exception.

Beamer version: beamer: ^1.6.1

To Reproduce

To temp fix this is my code, I do a if(context.watch<Foo?> == null) return SizedBox.shrink();.

Expected behavior Navigate from beam location A to beam location B without rebuilding the beamPage 'homePage' after beamToNamed is called.

Desktop (please complete the following information):

Sten435 commented 1 month ago

@slovnicki any updates ?

Sten435 commented 1 month ago

Found a solution.

Do not register, any providers in the builder(...) function in the location.

Instead if you want to wrap every page with a provider,

Extend beampage and wrap your providers arround the child proppety.

This works but is not pretty.

It should be fixed in beamer itself.