updateScrollIndicator method

  1. @override
void updateScrollIndicator(
  1. double? page,
  2. List<Size>? sizeList,
  3. Duration duration,
  4. ValueNotifier<IndicatorPosition> notifier,
)
override

Implementation

@override
void updateScrollIndicator(double? page, List<Size>? sizeList,
    Duration duration, ValueNotifier<IndicatorPosition> notifier) {
  ScrollItemInfo info =
      controller.calculateScrollTabbarItemInfo(page, sizeList!);
  if (info.nextItemSize.width == -1 &&
      info.nextItemSize.height == -1 &&
      !info.isLast) return;

  double left = 0;
  double right = 0;
  double top = 0;
  double bottom = 0;

  if (info.progress <= 0.5) {
    left = info.currentItemScrollEndOffset.dx -
        (info.currentItemSize.width + width) * 0.5;
    right = info.tabBarSize.width -
        info.currentItemScrollEndOffset.dx +
        info.currentItemSize.width * (0.5 - info.progress) -
        width * 0.5 -
        info.nextItemSize.width * info.progress;
  } else {
    left = info.currentItemScrollEndOffset.dx -
        width * 0.5 -
        info.nextItemSize.width * (0.5 - info.progress) -
        info.currentItemSize.width * (1 - info.progress);

    right = info.tabBarSize.width -
        info.currentItemScrollEndOffset.dx -
        (info.nextItemSize.width + width) * 0.5;
  }
  notifier.value = IndicatorPosition(left, right, top, bottom);
  controller.forEachListenerCallback();
}