list_smith library
A ListView.builder wrapper for async pagination, pull-to-refresh and search.
Classes
- AdvanceToFirstNonEmpty
- Pages past empty pages to the 1st one that has items, or to the true end.
- AsyncListSurfaces
- The overridable surfaces only an async list has: page loading, page errors, the end-of-list footer.
-
AsyncSearch<
T extends Object> - Async search on: a non-empty query switches the list to results fetched by fetchPage.
- EditTransition
- Whether the rows edits add and take animate, and how.
- EmptyPageBehaviour
- What an async list does when a page comes back empty but PaginationEndPolicy says more pages remain. Nothing on screen means nothing to scroll, so the list would otherwise sit there stuck.
- EmptyPageContext
- What an EmptyPageBehaviour sees when deciding whether to page past an empty page.
- EndContext
- What a PaginationEndPolicy sees when deciding whether an async list has run out of data.
- ExplicitHasMorePolicy
-
Ends pagination as soon as a page's fetcher reports
hasMore: false. - FailOnUnorderedPolicy
- Throws a StateError when pages arrive out of group order, in release too.
- FixedPageCountPolicy
- Ends pagination after pageCount pages, whatever those pages hold.
-
Grouping<
T extends Object> - How a list splits its items into labelled sections.
- GroupOrderPolicy
- What an async list does when its pages don't arrive grouped by key.
- KeepCachePolicy
- Keeps the feed across a search: put aside on the way in, restored when the query clears, so coming back is instant.
- ListScrollConfig
- The scroll and layout knobs, kept together so they don't crowd the behaviour parameters.
-
ListSmith<
T extends Object> - A list that handles async pagination and pull-to-refresh, or sync in-memory search.
-
ListSmithController<
T extends Object> - Drives a ListSmith.async list from code: a refresh button, a tab re-tap, a re-read after a local write, a logout.
- ListSmithObserver
- Lifecycle sink for a ListSmith.async list: logging, telemetry, analytics.
- ListSmithRefreshState
- The pull-to-refresh state at build time, handed to a RefreshIndicatorBuilder.
- LoggingListSmithObserver
-
A ListSmithObserver that logs every event to developer.log under the
list_smithname. - NoEditTransition
- No edit transitions: an edit shows at once. The default.
-
NoGrouping<
T extends Object> - No grouping: a flat list, no section headers. The default.
- NoRefresh
-
Pull-to-refresh off: no gesture, no indicator. Pass it to
.async'srefreshto opt out. - NoSearch
- No async search: a plain paginated feed. The default. Pass an AsyncSearch to turn search on.
-
PageFetcher<
T extends Object> - Fetches one page of items for an async list, from the PageRequest describing it.
- PageRequest
- The inputs of one page fetch, handed to a PageFetcher. Read-only.
- PaginationEndPolicy
- Decides when an async list has reached the end of its data.
- PullToRefresh
- Pull-to-refresh on, the default: a pull past the threshold reloads the list, from the 1st page unless reload says otherwise. Short content takes a pull too, whatever the scroll setup.
- Refresh
- Whether an async list has pull-to-refresh, and how its indicator is drawn.
- Reload
- What pull-to-refresh does to the pages already loaded.
- ReloadToCurrentDepth
- Re-fetches every loaded page, so a pull keeps the user's scroll depth instead of snapping back to the start.
- RepairHeadersPolicy
- Draws each group's header once, where the group first shows up. The default.
- ReplaceCachePolicy
- Starts every mode clean: entering search, leaving it and each new query all refetch from page 0. The default.
- ResetToFirstPage
- Throws away every loaded page and reloads just the 1st. The default: a pull puts the list back at the start with fresh data.
-
Search<
T extends Object> - Whether an async list is searchable, and how search behaves.
- SearchCachePolicy
- Decides what happens to an async list's cached items when it enters or leaves search.
-
SearchPageFetcher<
T extends Object> - Fetches one page of search results, from the SearchPageRequest describing it.
- SearchPageRequest
- The inputs of one search-page fetch, handed to a SearchPageFetcher. A PageRequest plus the committed query.
- ShowEmptySurface
- Shows the empty surface as soon as a page comes back with no items, fetching no further. The default.
- StopOnEmptyPagesPolicy
- Ends pagination after emptyRunBeforeEnd empty pages in a row. The default.
- StopOnNullSignalPolicy
-
Ends pagination when a page's fetcher returns a
nullend signal, after at least 1 page. - SyncSearchPredicates
- Ready-made SyncSearchPredicate builders for the usual shapes, built from field extractors.
Enums
- FetchTrigger
- Why list_smith asked for a page, carried on every PageRequest.
- ListSmithRefreshPhase
- The phase of a pull-to-refresh gesture, as handed to a RefreshIndicatorBuilder.
- PullableSurface
- A surface shown instead of the rows, which PullToRefresh.pullableSurfaces can let a pull refresh.
- ReloadOnError
- How a ReloadToCurrentDepth reload settles when a page fetch fails, after the fetcher's own retries.
Typedefs
- ErrorBuilder = Widget Function(BuildContext context, Exception error, VoidCallback onRetry)
- Builds the surface for a page whose fetch threw an Exception. An Error is a bug, so it goes on to the app instead.
-
GroupHeaderBuilder<
K extends Object> = Widget Function(BuildContext context, K key) -
Builds the header above a group's 1st item, from that group's
key. Once per group. -
GroupKeyOf<
T extends Object, K extends Object> = K Function(T item) -
Pulls the group key off
item, for a list showing its items in sections. -
ItemBuilder<
T extends Object> = Widget Function(BuildContext context, T item, int index) -
Builds one list item. The
indexis into the flattened list. -
ItemIdGetter<
T extends Object> = Object Function(T item) - Pulls a stable identity key off an item. The list drops an item whose key already showed up, an edit finds its row by it, and a row stays with its item as the rows around it change.
- NoResultsBuilder = Widget Function(BuildContext context, String query)
-
Builds the surface for a search that matched nothing, carrying the
querythat found none. - RefreshIndicatorBuilder = Widget Function(BuildContext context, ListSmithRefreshState state)
- Draws the pull indicator. Only called mid-pull, and list_smith decides where it sits.
-
SyncSearchPredicate<
T extends Object> = bool Function(T item, String query) - Decides whether an item matches a query, for a sync (in-memory) list.