isItemVisible method
bool
isItemVisible(
- ScrollController scrollController,
- dynamic index,
- List<
Size> ? sizeList, - Size tabBarSize,
判断item是否显示在可见区域
Implementation
bool isItemVisible(ScrollController scrollController, index,
List<Size>? sizeList, Size tabBarSize) {
var startOffset = getTargetItemScrollStartOffset(sizeList, index);
if (direction == Axis.horizontal) {
return scrollController.position.pixels < startOffset.dx &&
startOffset.dx < scrollController.position.pixels + tabBarSize.width;
}
return scrollController.position.pixels < startOffset.dy &&
startOffset.dy < scrollController.position.pixels + tabBarSize.height;
}