Skip to content

Instantly share code, notes, and snippets.

@Afonsocraposo

Afonsocraposo/main.dart Secret

Created Aug 11, 2019
Embed
What would you like to do?
_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