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

Flutter - How to assign multiple ScrollControllers to hide ScrollNavigationBar? #7

Open
ghost opened this issue Nov 14, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Nov 14, 2020

I have a ScrollBottomNavigationBar that scrolls up or down when it has a ScrollController attached to it. However as my valueListenable only listens to one scrollController, I cannot assign multiple ScrollControllers with the same valueListenable.

This is my ScrollBottomNavigationBar

ValueListenableBuilder<int>(
      valueListenable: controller.bottomNavigationBar.tabNotifier,
      builder: (context, value, child) {
        return Scaffold(
          bottomNavigationBar: ScrollBottomNavigationBar(
            controller: taskController,
            items: [
              BottomNavigationBarItem(
                  icon: Icon(Icons.plus), label: 'Page1'),
              BottomNavigationBarItem(
                  icon: Icon(Icons.plus), label: 'Page2'),
              BottomNavigationBarItem(
                  icon: Icon(Icons.plus), label: 'Page3'),
            ],
          ),
          body: Column(
            children: [
              Expanded(
                child: Container(
                  child: IndexedStack(
                    index: value,
                    children: <Widget>[
                     Page1(),
                      Page2(),
                      Page3(),
                    ],
                  ),
                ),
              ),
            ],
          ),
        );
      })

This is my Page1() -

return Scaffold(
    body: ValueListenableBuilder<int>(
      valueListenable: controller.bottomNavigationBar.tabNotifier,
      builder: (context, tabIndex, child) => ListView.builder(
        controller: controller,
        itemBuilder: ...,
      ),
    ),
  );

This is my Page2()-

return Scaffold(
    body: ValueListenableBuilder<int>(
      valueListenable: controller.bottomNavigationBar.tabNotifier,
      builder: (context, tabIndex, child) => ListView.builder(
        controller: controller, //I cannot return the same controller here
        itemBuilder: ...,
      ),
    ),
  );
@ghost ghost changed the title Flutter - How to assign multiple ScrollControllers to Navigation Bar? Flutter - How to assign multiple ScrollControllers to hide ScrollNavigationBar? Nov 16, 2020
@greyovo
Copy link

greyovo commented May 31, 2022

Did you solved this?

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

No branches or pull requests

1 participant