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
- Manual pagination with offset/limit - loses reactivity to database changes
- 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?
FloorDBthen your data set already converted to yourDAO, do you mean thatFloorDBis slow when creating the list with allDAO(in worst case 3000) objects?limitandoffsetbut 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