Overriding builder method of BeamLocation

180 Views Asked by At

I am currently trying to build a flutter app using Beamer and Provider. The app should have a BottomNavbar and remember the state of each tab when switching. Currently I am doing that by using nested Beamers with an IndexedStack. Now I want to have a BeamLocation with multiple pages, that all share a common state. To do that I want to wrap the entire BeamLocation with a ChangeNotifierProvider. However when doing that, the app tries to build a Location of the wrapped BeamLocation after it already is on another BeamLocation. I am pretty sure the issue is with the builder method of BeamLocation:

When overriding it like this:

@override
Widget builder(BuildContext context, Widget navigator) => navigator

It works fine, which is expected since it doesn't really do anything. But if I change it to this:

  @override
  Widget builder(BuildContext context, Widget navigator) {
    return Container(
      child: navigator,
    );
  }

It tries to build a page of that location, even when a different location from another BeamLocation is already active. For a container this isn't a problem, but since I am trying to wrap the BeamLocation with a Provider as stated in the documentation, it is. When doing that, the extra build happens after the Provider is already gone, causing an error.

0

There are 0 best solutions below