robert-luoqing / flutter_list_view

MIT License
47 stars 17 forks source link

ensureVisible issue,the offset need to increase scrollOffset #18

Closed huage2580 closed 4 months ago

huage2580 commented 2 years ago
@@ -205,10 +205,11 @@ class FlutterListViewElement extends RenderObjectElement {
    // paintedElements
    var flutterListViewRender = renderObject as FlutterListViewRender;
    var viewportHeight = flutterListViewRender.currentViewportHeight ?? 0;
+   var scrollOffset = flutterListViewRender.currentScrollOffset ?? 0.0;
    for (var item in flutterListViewRender.paintedElements) {
      if (item.index == index &&
          item.offset > 0 &&
-          item.offset + item.height < viewportHeight) {
+          item.offset + item.height <= viewportHeight + scrollOffset) {
        return;
      }
    }
robert-luoqing commented 1 year ago

@huage2580 I don't think ensureVisible will work on the library. As you know, the flutter_list_view will reuse the items which invisible in viewport. For example, If item1 is not visble in current window, It will reused in item10 if item10 will show in viewpoint.