slovnicki / beamer

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

Beamer not retaining state of previous screen #635

Open kdomingo opened 1 year ago

kdomingo commented 1 year ago

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

jenisnavadiya commented 1 year ago

Same issue

felixdollack commented 1 year 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 1 year ago

There was also this comment that could be useful

stan-at-work commented 2 months ago

@kdomingo could this isseu be closed ?