isInTarbarVisible method

bool isInTarbarVisible(
  1. dynamic index,
  2. Size tabBarViewSize,
  3. List<Size>? sizeList,
  4. ScrollController scrollController,
)

Implementation

bool isInTarbarVisible(
  index,
  Size tabBarViewSize,
  List<Size>? sizeList,
  ScrollController scrollController,
) {
  final pixels = scrollController.position.pixels;
  final startStartOffset = getTargetStartOffset(sizeList, index);
  final startEndOffset = getTargetEndOffset(sizeList, index);
  final tabBarViewWidth = tabBarViewSize.width;
  final tabBarViewHeight = tabBarViewSize.height;
  final offsetStartX = startStartOffset.dx;
  final offsetStartY = startStartOffset.dy;
  final offsetEndX = startEndOffset.dy;
  final offsetEndY = startEndOffset.dy;

  // offsetEnd == pixels, -> tab end is tabBarView start boundary
  // offsetStart == pixels + tabBarViewWidth, -> tab start is tabBarView end boundary
  return direction == Axis.horizontal
      ? offsetEndX > pixels && offsetStartX < pixels + tabBarViewWidth
      : offsetEndY > pixels && offsetStartY < pixels + tabBarViewHeight;
}