getDisplayedPositionFromList method

int? getDisplayedPositionFromList()

Implementation

int? getDisplayedPositionFromList() {
  final value = itemPositionsListener.itemPositions.value;
  if (value.length < 1) {
    return null;
  }
  final orderedListByPositionIndex = value.toList()
    ..sort((a, b) => a.index.compareTo(b.index));

  final renderedMostTopItem = orderedListByPositionIndex.first;
  if (renderedMostTopItem.getBottomOffset(_currentPositionedListSize) <
      widget.earlyChangePositionOffset) {
    if (orderedListByPositionIndex.length > 1) {
      return orderedListByPositionIndex[1].index;
    }
  }
  return renderedMostTopItem.index;
}