robert-luoqing / flutter_list_view

MIT License
45 stars 17 forks source link

The cacheExtent is directly set to viewportHeight on removeOutOfScopeElements() instead of constraints.cacheOrigin? #37

Open kmmk42000 opened 2 months ago

kmmk42000 commented 2 months ago

In method performLayout(), set targetStartScrollOffset = constraints.scrollOffset + constraints.cacheOrigin

final double targetStartScrollOffset =
    constraints.scrollOffset + constraints.cacheOrigin;
final double targetEndScrollOffset =
    targetStartScrollOffset + constraints.remainingCacheExtent;

but In method removeOutOfScopeElements(), set cacheExtent = viewportHeight without constraints.cacheOrigin.

void removeOutOfScopeElements(double scrollOffset, double viewportHeight) {
  double cacheExtent = viewportHeight;
  double startOffset = scrollOffset - cacheExtent;
  if (startOffset < 0) {
    startOffset = 0;
  }
  double endOffset = scrollOffset + viewportHeight + cacheExtent;
}

I wanna know why not using constraints.cacheOrigin In method removeOutOfScopeElements()?