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

NotFound on hot reload #583

Open vixez opened 1 year ago

vixez commented 1 year ago

Describe the bug When I navigate to a specific route, and then hot reload it shows the NotFound screen. However before the hot reload it showed the correct screen.

Beamer version: 1.5.3

To Reproduce Route

const String kHomeIncentiveDetailConfirmOrderRoute =
    '/home/incentive/$kIncentiveIdRoute/confirm-order';

// Parameters
const String kIncentiveId = 'incentiveId';
const String kIncentiveIdRoute = ':$kIncentiveId';

Location


class TabIncentivesLocation extends BeamLocation<BeamState> {
  TabIncentivesLocation(RouteInformation routeInformation)
      : super(routeInformation);

  @override
  List<String> get pathPatterns => [
        kHomeIncentivesTabRoute,
        kHomeIncentiveDetailRoute,
        kHomeIncentiveDetailConfirmOrderRoute,
        '$kHomeRoute/*',
      ];

  @override
  List<BeamPage> buildPages(BuildContext context, BeamState state) => [
        const BeamPage(
          key: ValueKey('incentives'),
          type: BeamPageType.noTransition,
          child: TabIncentives(),
        ),
        if (state.pathParameters.containsKey(kIncentiveId) &&
            !state.uri.pathSegments.contains('confirm-order'))
          BeamPage(
            key: ValueKey(
                'incentive/${state.pathParameters[kIncentiveId]}/detail'),
            type: BeamPageType.material,
            child: TabIncentivesDetail(
              id: int.parse(state.pathParameters[kIncentiveId]!),
            ),
          ),
        if (state.pathParameters.containsKey(kIncentiveId) &&
            state.uri.pathSegments.contains('confirm-order'))
          BeamPage(
            key: ValueKey(
                'incentive/${state.pathParameters[kIncentiveId]}/confirm-order'),
            type: BeamPageType.material,
            child: TabIncentivesConfirmOrder(
              id: int.parse(state.pathParameters[kIncentiveId]!),
            ),
          ),
      ];
}

Navigating:

Beamer.of(context).beamToNamed(
                  kHomeIncentiveDetailConfirmOrderRoute.replaceAll(
                    kIncentiveIdRoute,
                    '${incentive.id}',
                  ),
                  data: incentive,
                );

Expected behavior Hot reloading does not result in NotFound.

Additional context This does not happen on every route, but this one is consistent. What am I doing wrong?

MadGeorge commented 1 year ago

I'm also interested in what is the cause of this behavior.