Shirish Koirala
Shirish Koirala

Reputation: 63

What is the memory efficient way to load 7000+ items in list view in flutter form sqlite database

I am new to flutter and creating an app that has more than 7000+ items preloaded into a database. I want to display all those items in a list view. I am currently querying the database once and loading all in memory and displaying it using ListView class as such.

ListView.separated(
 separatorBuilder: (context, int) {
  return Divider(height: 0);
 },
 controller: scrollController,
 padding: const EdgeInsets.only(top: 5, bottom: 5),
 itemCount: data.length,
 itemBuilder: (context, int position) {
  Map<String, dynamic> value = data[position];
   return ListTile(title: value['value']);
 },
);

I find that by doing this my list view is laggy and is not performing well. Is this the right way? or may be I am doing this right but screwing some thing else?

Upvotes: 1

Views: 554

Answers (1)

mdexp
mdexp

Reputation: 3567

Is your list view lagging in the release build as well?

Keep in mind that when you run the non-release version of your app it lacks some optimizations and performance improvements. Therefore give it a try with the release compiled apk.

Upvotes: 1

Related Questions