previousView method
Animates the controlled pages/tabs to the previous page/tab.
The animation lasts for the default duration and follows the default curve. The returned Future resolves when the animation completes.
Implementation
Future<void> previousView() async {
if (_tabController != null) {
if (index - 1 >= 0) {
final future = Completer();
_tabController!.animateTo(
index - 1,
duration: (this as InjectedPageTabImp).duration,
curve: (this as InjectedPageTabImp).curve,
);
if ((this as InjectedPageTabImp).duration == Duration.zero) {
return;
}
late void Function(AnimationStatus) listener;
listener = (status) {
if (status == AnimationStatus.completed) {
future.complete();
_tabController!.animation?.removeStatusListener(listener);
}
};
_tabController!.animation?.addStatusListener(listener);
return future.future;
}
} else {
assert(_pageController != null);
return _pageController!.previousPage(
duration: (this as InjectedPageTabImp).duration,
curve: (this as InjectedPageTabImp).curve,
);
}
}