Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cacheExtent] is ineffective #9

Closed
jiangtian616 opened this issue Apr 12, 2022 · 4 comments
Closed

[cacheExtent] is ineffective #9

jiangtian616 opened this issue Apr 12, 2022 · 4 comments

Comments

@jiangtian616
Copy link

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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Owner

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

Thanks

@jiangtian616
Copy link
Author

Thanks a lot, it takes effect now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants