How to handle large list of objects in dart / flutter apps?

Viewed 15

I am stuck in a situation where I need to store very large list of dart object in my application

I wanted to know if there is any better way of storing dart objects to avoid memory overflows

this is my Product class

class Product {
  final String id;
  final String productCode;
  // each url will be approximately 256 characters long and each product will have minimum of 10 images
  final List<String> images;
  final String designNumber;
  final String itemStatus;
  final String location;
  final String itemCategory;
}

In my application I have approximately 5,00,000 products which I have to store inside List during application runtime

but when I cross approximately 1,00,000 products I get memory overflow error

1 Answers

What you should do is to use pagination, so that you can break all that data into batches, or if it's not page data you can do conditional pulling so that during scroll, a new API call is make to the API to load data from a particular range.

See here for an example

Related