Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to animate the transition between the tabs of a CupertinoTabScaffold?

I'm using the sample below (taken from the CupertinoTabScaffold documentation page).

There is a "slide" transition when pushing a new route inside the tab, but when I click on a tabbar item, the content is brutally replaced. How can I have a transition when switching between tabs?

I would like implement something like that: https://github.com/Interactive-Studio/TransitionableTab

CupertinoTabScaffold(
  tabBar: CupertinoTabBar(
    items: [
      BottomNavigationBarItem(
        icon: Icon(CupertinoIcons.home),
        title: Text("Tab 0"),
      ),
      BottomNavigationBarItem(
        icon: Icon(CupertinoIcons.news),
        title: Text("Tab 1"),
      ),
    ],
  ),
  tabBuilder: (BuildContext context, int index) {
    return CupertinoTabView(
      builder: (BuildContext context) {
        return CupertinoPageScaffold(
          navigationBar: CupertinoNavigationBar(
            middle: Text('Page 1 of tab $index'),
          ),
          child: Center(
            child: CupertinoButton(
              child: const Text('Next page'),
              onPressed: () {
                Navigator.of(context).push(
                  CupertinoPageRoute<void>(
                    builder: (BuildContext context) {
                      return CupertinoPageScaffold(
                        navigationBar: CupertinoNavigationBar(
                          middle: Text('Page 2 of tab $index'),
                        ),
                        child: Center(
                          child: CupertinoButton(
                            child: const Text('Back'),
                            onPressed: () { Navigator.of(context).pop(); },
                          ),
                        ),
                      );
                    },
                  ),
                );
              },
            ),
          ),
        );
      },
    );
  },
)
like image 740
ncuillery Avatar asked Feb 24 '20 00:02

ncuillery


1 Answers

May be this package will be help you page_transition: ^2.0.5 https://pub.dev/packages/page_transition

like image 150
Kumaresan Jackie Avatar answered Jun 14 '23 15:06

Kumaresan Jackie