robert-luoqing / flutter_list_view

MIT License
47 stars 17 forks source link

bug in pageDown function #34

Closed graemep-nz closed 5 months ago

graemep-nz commented 5 months ago

Line 269 in flutter_list_view_element.dart needs to be replaced by the following three lines - "childCount minus one" is the max value that can be passed to jumpToIndex. (This was my bug I think, apologies)

  if (childCount > 0) {
    jumpToIndex(childCount - 1, 0, true);
  }
  void pageDown() {
    var flutterListViewRender = renderObject as FlutterListViewRender;
    var viewportHeight = flutterListViewRender.currentViewportHeight ?? 0;
    var sdata = getVisibleIndexData();
    int first = sdata[0];
    int last = sdata[1];
    double totalHeight = sdata[2];
    if (totalHeight <= viewportHeight) {
      // perfect alignment
      if (last + 1 < childCount) {
        jumpToIndex(last + 1, 0, false);
        return;
      }
      jumpToIndex(childCount, 0, true);   // <<<<<<<<<<<<  bug
      return;
    }
    jumpToIndex(last, 0, false);
  }
robert-luoqing commented 5 months ago

changed and released, thanks.