Skip to content

🐛 interference in _NavigationBodyState between PageView and paneBodyBuilder/IndexedStack #679

@klondikedragon

Description

@klondikedragon

Describe the bug
I've recently upgraded fluent_ui from 4.0.1 to 4.1.4, and started to receive all kinds of odd/random issues. e.g., duplicate GlobalKeys in widgets related to a nested vrouter, stateful widgets being disposed almost immediately after creation (causing futures executed in a "zero" delay created in an initState that reference the build context to get an exception that the widget was already detached), widgets not having a sized viewport during construction, etc.

It appears this is related to the recent enhancements (#607, #645) surrounding preserving state of navigation pane items through the ability to specify a key for each pane item. This is a great enhancement and good when the use of navigation pane is simple (common use case for most apps probably). In my case, I need to manage the keys/state of the widgets presented within the body of the navigation pane explicitly (and underneath an IndexedStack) because the content is not determined just by the currently selected pane, but also by the current route, which could include sub-routes that reference tabs with different content. (A sketch of what is being done is in #226 (comment) ).

It appears that using an IndexedStack in combination with paneBodyBuilder is contemplated (somewhat discussed in #649 (comment)).

I'm not exactly sure why, but the new PageView.builder (with an automatic GlobalKey passed to it) is really interfering strongly with the IndexedStack returned by my paneBodyBuilder.

I've tested a solution that seems to work nicely, where if the paneBodyBuilder is not null then it just doesn't wrap the widget built by the paneBodyBuilder in the PageView.builder (nor does it use the _pageKey in _NavigationBodyState) and that removes all of the problems.

I've created a PR for consideration to fix this issue and #678.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions