api/stream_helpers library

Classes

PagedResult<T>
Result of a paginated stream collection.

Constants

kDefaultPagedResultLimit → const int
Default max items returned by collectStream (pageSize 50 * maxPages 10). Used by UI screens to determine if "Load More" / "hasMore" should be shown.

Functions

collectStream<R, T>(Stream<R> stream, {required List<T> extract(R response), int maxPages = 10}) Future<List<T>>
Collects items from a paginated server stream with a maximum page cap to prevent unbounded memory growth.
collectStreamPaged<R, T>(Stream<R> stream, {required List<T> extract(R response), int maxPages = 10}) Future<PagedResult<T>>
Like collectStream but also returns whether more pages are available.
countStream<R>(Stream<R> stream, {required int count(R response), int maxPages = 20}) Future<int>
Counts items from a paginated server stream with a maximum page cap. Only accumulates the count, not the items themselves.