Skip to content

The state of the main body is lost when navigating to the details page #2

@Hannnes1

Description

@Hannnes1

Hi,
I like your example, but I found one issue.
It can be observed if you scroll down in one of the lists, and then click on an item. The details page then opens, but scroll position in the list is lost.

One possible solution I had in mind was to reuse the same page, something like this:

StatefulShellBranch(
initialLocation: '/nav1/null',
navigatorKey: _nav1NavigatorKey,
routes: [
GoRoute(
  name: AppRouter.nav1Details,
  path: '/nav1/:id',
  pageBuilder: (context, state) => NoTransitionPage(
    child: AppScaffold(
      body: NavListScreen(
        key: state.pageKey,
        listId: 1,
      ),
      secondaryBody: state.pathParameters["id"] == 'null'
          ? null
          : DetailsScreen(
              id: state.pathParameters["id"],
            ),
    ),
  ),
),

That does retain the state of the list correctly, but it also means that there is no way to navigate back from the details page.
I also tried to figure something out with keys, but couldn't get that to work either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions