Skip to content

Instantly share code, notes, and snippets.

@afonsocraposo
Created August 11, 2019 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afonsocraposo/80f51fb90dae05078be008b2ae264a56 to your computer and use it in GitHub Desktop.
Save afonsocraposo/80f51fb90dae05078be008b2ae264a56 to your computer and use it in GitHub Desktop.
_setCurrentIndex & _triggerAnimation
_setCurrentIndex(int index) {
// if we're actually changing the index
if (index != _currentIndex) {
setState(() {
// change the index
_currentIndex = index;
});
// trigger the button animation
_triggerAnimation();
// scroll the TabBar to the correct position (if we have a scrollable bar)
_scrollTo(index);
}
}
_triggerAnimation() {
// reset the animations so they're ready to go
_animationControllerOn.reset();
_animationControllerOff.reset();
// run the animations!
_animationControllerOn.forward();
_animationControllerOff.forward();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment