0

Problem Description

I'm building a Flutter app that needs to display a large dataset (100-3000 rows, ~30 fields each) in a ListView with the following requirements:

  • Local database as Single Source of Truth (SSOT) - data comes from FloorDB
  • Lazy loading - only load visible items + buffer
  • Reactive UI - ListView updates automatically when database changes
  • Memory efficient - avoid loading entire dataset into memory

Current Implementation Issues

Currently using a Stream-based approach that returns the entire dataset:

Stream<List<Record>> watchRecords();

Problems with this approach:

  • Initial load is slow (0.5-1.5 seconds for 500 items)
  • High memory usage
  • UI freezes during large dataset updates

What I Need

Something equivalent to Android's Jetpack Paging3 which provides:

  • Automatic pagination with configurable page sizes
  • Built-in loading states and error handling
  • Seamless integration with local Room database
  • Memory-efficient lazy loading
  • Reactive updates when underlying data changes

Attempted Solutions

  1. Manual pagination with offset/limit - loses reactivity to database changes
  2. infinite_scroll_pagination - doesn’t support reactivity, requires complex logic to find page of an element and manual updates

How complex would it be to build a custom solution that maintains both lazy loading AND database reactivity?

3
  • if it comes from FloorDB then your data set already converted to your DAO, do you mean that FloorDB is slow when creating the list with all DAO (in worst case 3000) objects? Commented Jun 4 at 11:07
  • Measurements in Flutter profiling are showing so. Besides, holding all the 3000 objects in memory doesn't seem efficient to me. I need to load objects to memory on demand rather than as a whole. Commented Jun 4 at 13:34
  • you could use limit and offset but I don't think you will get much extra performance gain if it's only max 3000 items, more on that: secoda.co/learn/understanding-limit-and-offset-in-sql Commented Jun 4 at 19:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.