nextView method

Future<void> nextView()

Animates the controlled pages/tabs to the next 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> nextView() async {
  if (_tabController != null) {
    if (index + 1 < _tabController!.length) {
      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!.nextPage(
      duration: (this as InjectedPageTabImp).duration,
      curve: (this as InjectedPageTabImp).curve,
    );
  }
}