showMorePage function
The page a "Show more" list shows: revealed items of the loaded ones,
and what is left of the total (all documents the query matches, when
counted) or of what hasMoreToFetch says Firestore still has.
Implementation
ShowMorePage showMorePage({
required int loaded,
required int revealed,
required bool hasMoreToFetch,
int? total,
}) {
final int shown = revealed < loaded ? revealed : loaded;
final int? remaining = total != null
? (total - shown).clamp(0, total)
: hasMoreToFetch
? null
: loaded - shown;
return (
shown: shown,
remaining: remaining,
hasMore: shown < loaded || hasMoreToFetch || (remaining ?? 0) > 0,
);
}