FirestorePagination class

A StreamBuilder that automatically loads more data when the user scrolls to the bottom.

Optimized for FirebaseFirestore with fields like createdAt and timestamp to sort the data.

Supports live updates and realtime updates to loaded data.

Data can be represented in a ListView, GridView or scollable Wrap.

Inheritance

Constructors

FirestorePagination({required Query<Object?> query, required Widget itemBuilder(BuildContext, DocumentSnapshot<Object?>, int), Key? key, Widget separatorBuilder(BuildContext, int)?, int limit = 10, ViewType viewType = ViewType.list, bool isLive = false, SliverGridDelegate gridDelegate = const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2), WrapOptions wrapOptions = const WrapOptions(), Widget onEmpty = const EmptyScreen(), Widget bottomLoader = const BottomLoader(), Widget initialLoader = const InitialLoader(), Axis scrollDirection = Axis.vertical, bool reverse = false, bool shrinkWrap = false, ScrollPhysics? physics, EdgeInsetsGeometry? padding, ScrollController? controller})
Creates a StreamBuilder widget that automatically loads more data when the user scrolls to the bottom.
const

Properties

bottomLoader Widget
The widget to use when more data is loading.
final
controller ScrollController?
The scroll controller to use for the ScrollView.
final
gridDelegate SliverGridDelegate
The delegate to use for the GridView.
final
hashCode int
The hash code for this object.
no setterinherited
initialLoader Widget
The widget to use when data is loading initially.
final
isLive bool
Whether to fetch newly added items as they are added to Firestore.
final
itemBuilder Widget Function(BuildContext, DocumentSnapshot<Object?>, int)
The builder to use to build the items in the list.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
limit int
The number of items to fetch from Firestore at once.
final
onEmpty Widget
The widget to use when data is empty.
final
padding EdgeInsetsGeometry?
The padding to use for the ScrollView.
final
physics ScrollPhysics?
The scroll behavior to use for the ScrollView.
final
query → Query<Object?>
The query to use to fetch data from Firestore.
final
reverse bool
Whether the ScrollView scrolls in the reading direction.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollDirection Axis
The scrolling direction of the ScrollView.
final
separatorBuilder → (Widget Function(BuildContext, int)?)
The builder to use to render the separator.
final
shrinkWrap bool
Should the ScrollView be shrink-wrapped.
final
viewType ViewType
The type of view to use for the list.
final
wrapOptions WrapOptions
The Wrap widget properties to use.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<FirestorePagination>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited