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

Beamer not retaining state of previous screen #635

Open kdomingo opened 10 months ago

kdomingo commented 10 months ago

Navigating to an item's details screen and going back makes the list screen rebuild.

jenisnavadiya commented 10 months ago

Same issue

felixdollack commented 9 months ago

I noticed the same. It seems state is only kept when the previous screen is part of the location stack.

E.g. going from LocationA -> LocationB

class LocationB extends BeamLocation<BeamState> {
  @override
  List<BeamPage> buildPages(BuildContext context, BeamState state) {
    return [
      // create whatever (back)stack you desire here.
      // this will also keep the current state of this location in memory
      ...LocationA().buildPages(context, state),
      const WidgetB(),
    ];
  }

  @override
  List<Pattern> get pathPatterns => ["/b"];
}

Disclaimer: I just started using beamer 2 days ago. There could be another way I don't know yet ^^;

felixdollack commented 9 months ago

There was also this comment that could be useful