pageController property

  1. @override
PageController get pageController
override

Get the associated PageController

Implementation

@override
PageController get pageController {
  _OnTabPageViewBuilderState._addToTabObs?.call(this);

  if (_pageController != null) {
    return _pageController!;
  }

  _pageController = PageController(
    initialPage: initialIndex,
    keepPage: keepPage,
    viewportFraction: viewportFraction,
  );

  _pageController!.addListener(() {
    if (snapState.data == _page!) {
      return;
    }
    if (_tabController?.indexIsChanging == true) {
      return;
    }
    if (_tabController != null) {
      _pageIndexIsChanging = true;
      if (_page! >= _tabController!.length) {
        return;
      }
      _tabController?.animateTo(
        _page!,
        duration: duration,
        curve: curve,
      );
      _pageIndexIsChanging = false;
    } else {
      snapValue = const SnapState<int>.none().copyToHasData(_page!);
      notify();
    }
  });

  return _pageController!;
}