beamer icon indicating copy to clipboard operation
beamer copied to clipboard

[Help / Improvement] Data object inside Beam Location

Open FrBernad opened this issue 2 years ago • 1 comments

What's the equivalent of the data parameter for a Location Builder using a Beam Location?

The RoutersLocationBuilder receives a data parameter, but It's not the case with the buildPages of a locationBuilder.

  • RouterLocationBuilder: '/': (context, state, data) => HomeScreen(),
  • Beam Location: List<BeamPage> buildPages(BuildContext context, BeamState state)

Reading the source code I find out that the data object is added as property to the currentLocation, but that is after the build pages method is called, so there is not way of accessing that instance of the data object in the buildPages method.

Accessing the current data object inside the build pages method should be a thing right?

FrBernad avatar Apr 03 '23 22:04 FrBernad

Hey @FrBernad :wave: Thanks for creating an issue and sorry for my absence lately.

Indeed, data is a public property of BeamLocation so it can be accessed freely. Fun fact; so is the state, but it was added as a parameter to buildPages out of convenience, because it is literary always used. I was thinking of adding data too...

data should be set before buildPages is called :thinking: It is set in the update (the function that all the beamTo* functions call) and buildPages is called during build, which is triggered at the end of update.

Do you have a small example that demonstrates how data is not available during buildPages?

slovnicki avatar Jun 03 '23 17:06 slovnicki