setActiveIndex method

void setActiveIndex(
  1. int index, {
  2. bool notify = true,
})

Updates _activeIndex and triggers a rebuild

Implementation

void setActiveIndex(int index, {bool notify = true}) {
  assert(index >= 0 && index < _pages.length);
  if (_activeIndex != index) {
    final didPreload = preload(index);
    _previousIndex = _activeIndex;
    _activeIndex = index;
    if (notify) {
      if (didPreload && SchedulerBinding.instance.schedulerPhase != SchedulerPhase.idle) {
        SchedulerBinding.instance.addPostFrameCallback((_) {
          notifyAll();
        });
      } else {
        notifyAll();
      }
    }
  }
}