Milad-Akarie / auto_route_library

Flutter route generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using AutoTabsRouter.tabBar with SliverAppBar

wesjeong opened this issue · comments

Hi there.

I am building an app using AutoTabsScaffold with BottomNavigationBar on my homepage, which has multiple pages.
One of the pages in the homepage uses AutoTabsRouter.tabBar inside of it. Even with the tab views each being a ListView, everything is perfect. Scrolling works just fine.

However, the problem I am facing is that I want the TabBar to become a SliverAppBar. As I start scrolling down the ListView, I want the TabBar to disappear smoothly. Currently I have this code, SliverAppBar doesn't start its animation when scrolling the child.

  @override
  Widget build(BuildContext context) {
    return AutoTabsRouter.tabBar(
        routes: const [
          ARouter(),
          BRouter(),
          CRouter(),
        ],
        builder: (context, child, controller) {
          return Scaffold(
            body: NestedScrollView(
              headerSliverBuilder: (context, innerBoxIsScrolled) {
                return <Widget>[
                    SliverAppBar(
                      title: const Text('AppBar'),
                      bottom: TabBar(
                        controller: controller,
                        tabs: const [
                          Tab(text: '1', icon: Icon(Icons.abc)),
                          Tab(text: '2', icon: Icon(Icons.abc)),
                          Tab(text: '3', icon: Icon(Icons.abc)),
                        ],
                      ),
                    ),
                  // )
                ];
              },
              body: child,
            ),
          );
        });
  }

I've also tried using CustomScrollView but I also did not have any luck with it.
Is there a way to achieve the behavior that I want?

@wesjeong your code works fine out side of an AutoTabsRouter.tabBar?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions