animateTo method
change active tab index; can be used with PageView.
Implementation
Future<void> animateTo(int index, {int? from}) async {
var gap = DateTime.now().millisecondsSinceEpoch - _previousTimestamp;
_updateAnimation(
from: from ?? _currentIndex,
to: index,
duration: Duration(
milliseconds: gap < _TRANSITION_DURATION ? 0 : _TRANSITION_DURATION),
);
// ignore: unawaited_futures
_animationController?.forward();
if (mounted) {
setState(() {
_currentIndex = index;
});
}
_previousTimestamp = DateTime.now().millisecondsSinceEpoch;
}