Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i check NavigationPane is open in PaneDisplayMode.compact ? #758

Closed
thitlwincoder opened this issue Mar 8, 2023 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@thitlwincoder
Copy link
Contributor

I want to use multiple crossAxisCount in GridView like below. How can i check ?

GridView.builder(
      shrinkWrap: true,
      itemCount: 10,
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: isOpen ? 3 : 4,
      ),
      itemBuilder: (context, index) {
        return itemUI(index);
      },
)
@h3x4d3c1m4l
Copy link
Contributor

h3x4d3c1m4l commented Mar 9, 2023

Hi! I checked the API. Using a GlobalKey<NavigationViewState> one can know whether the minimal pane is open, but that won't help you with the compact pane. As of now there seems to be no way of getting this.

Maybe you could change the crossAxisCount based on the space you have available by wrapping your widget with a LayoutBuilder?

@bdlukaa
Copy link
Owner

bdlukaa commented Mar 9, 2023

@h3x4d3c1m4l Indeed, there is no current api in NavigationViewState to account for that. As a workaround, you can try to do the following in the children of NavigationView:

final isOpen = PageStorage.of(context).readState(
          context,
          identifier: 'compactOverlayOpen',
        ) as bool?

@bdlukaa bdlukaa added the enhancement New feature or request label Mar 9, 2023
@thitlwincoder
Copy link
Contributor Author

@bdlukaa Yes. it really work, but NavigationPaneItems kept refreshing, how can I make keep alive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants