robert-luoqing / flutter_list_view

MIT License
45 stars 17 forks source link

[cacheExtent] is ineffective #9

Closed jiangtian616 closed 2 years ago

jiangtian616 commented 2 years ago

Hi! Thanks for your great work, but i'm stuck in setting cacheExtent.

Example code:

class HomePage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return FlutterListView(
      cacheExtent: 500,
      delegate: FlutterListViewDelegate(
        (context, index) {
          print(index);
          return Container(color: Colors.red, height: 50);
        },
        childCount: 500,
        onItemKey: (index) => index.toString(),
        onItemHeight: (index) => 50,
      ),
    );
  }
}

For my device, enter this page will get index outputs 1 to 34. But if i change cacheExtent to another value(no matter what its value is), the outputs is always same(1 to 34). I wonder if there's any mistake in my code?

robert-bitguild commented 2 years ago

It is not an error because FlutterListView ignored the cacheExtent based on the reused existing items. I worked with React Native. I guess the cacheExtent is used to resolve the scrolling smooth issue. Here is not necessary to implement it.

But I will implement it if you have a special requirement that needs cacheExtent.

jiangtian616 commented 2 years ago

It is not an error because FlutterListView ignored the cacheExtent based on the reused existing items. I worked with React Native. I guess the cacheExtent is used to resolve the scrolling smooth issue. Here is not necessary to implement it.

But I will implement it if you have a special requirement that needs cacheExtent.

Yes. I'm working on a network image list and my target is to manually set image preload count. So if cacheExtent takes effect, i can simply increase preload count by enlarge the value of cacheExtent, which i think is the simplest method. Otherwise i may consider other way like precacheImage. So if it's convenient for you to implement this feature, i would be very appreciated. :)

robert-luoqing commented 2 years ago

@jiangtian616 The lib has implemented cacheExtent, please update it to flutter_list_view: ^1.1.13.

Thanks

jiangtian616 commented 2 years ago

Thanks a lot, it takes effect now.