therezacuet / Motion-Tab-Bar

A beautiful animated flutter widget package library. The tab bar will attempt to use your current theme out of the box, however you may want to theme it.
MIT License
293 stars 74 forks source link

animateTo isn't working #17

Closed myThorsten closed 3 years ago

myThorsten commented 3 years ago

I'm using the following code to change to displayed tab on swipe-right or swipe-left via code. Please note the _tabController.animateTo:

        body: GestureDetector(
          onHorizontalDragEnd: (drawEndDetails) {
            print(drawEndDetails);
            if (drawEndDetails.primaryVelocity > 0.0 && _tabController.index > 0) {
              setState(() => _tabController.animateTo(_tabController.index - 1));
            } else if (drawEndDetails.primaryVelocity < 0.0 && _tabController.index < _labels.length - 1) {
              setState(() => _tabController.animateTo(_tabController.index + 1));
            }
          },
          child: MotionTabBarView(
            controller: _tabController,
            children: [
              ContactCreateHistory(encounter: widget._encounter),
              ContactCreateContacts(encounter: widget._encounter),
              ContactCreateMaps(encounter: widget._encounter),
              ContactCreateFormular(encounter: widget._encounter),
            ],
          ),
        ),

The displayed content is updated correctly, but not the tab-display. it is not animating nor updated.

Before swipe, on the first tab: image After swipe, tab-content updated to second tab, should be focusing red circled tab: image

Am I doing something wrong?

myThorsten commented 3 years ago

Not longer relevant

neilgoyal commented 3 years ago

What is the solution

neilgoyal commented 3 years ago

@myThorsten @therezacuet