Skip to content

Commit 484162c

Browse files
feat: return entire snapshot, instead of one doc a time in itemBuilder (#48)
* return list<snapshots> * Update build_pagination.dart * revert changes in line 90 * refactor: updated example app with new changes --------- Co-authored-by: OutdatedGuy <everythingoutdated@gmail.com>
1 parent 868aabc commit 484162c

File tree

7 files changed

+49
-25
lines changed

7 files changed

+49
-25
lines changed

example/lib/firestore_pagination_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class _FirestorePaginationExampleState
4040
padding: const EdgeInsets.all(8.0),
4141
separatorBuilder: (context, index) => const Divider(),
4242
itemBuilder: (context, snapshot, index) {
43-
final msg = snapshot.get('text');
43+
final msg = snapshot[index].get('text');
4444

4545
return ListTile(
4646
shape: RoundedRectangleBorder(

example/lib/realtimedb_pagination_ascending_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class _RealtimeDBAscendingPaginationExampleState
4343
child: Text('No TODO tasks found!!!'),
4444
),
4545
itemBuilder: (context, snapshot, index) {
46-
final msg = snapshot.child('text').value as String?;
46+
final msg = snapshot[index].child('text').value as String?;
4747

4848
return ListTile(
4949
shape: RoundedRectangleBorder(

example/lib/realtimedb_pagination_descending_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class _RealtimeDBDescendingPaginationExampleState
4545
child: Text('No messages found!!!'),
4646
),
4747
itemBuilder: (context, snapshot, index) {
48-
final msg = snapshot.child('text').value as String?;
48+
final msg = snapshot[index].child('text').value as String?;
4949

5050
return ListTile(
5151
shape: RoundedRectangleBorder(

example/pubspec.lock

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,30 @@ packages:
167167
url: "https://pub.dev"
168168
source: hosted
169169
version: "0.6.7"
170+
leak_tracker:
171+
dependency: transitive
172+
description:
173+
name: leak_tracker
174+
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
175+
url: "https://pub.dev"
176+
source: hosted
177+
version: "10.0.4"
178+
leak_tracker_flutter_testing:
179+
dependency: transitive
180+
description:
181+
name: leak_tracker_flutter_testing
182+
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
183+
url: "https://pub.dev"
184+
source: hosted
185+
version: "3.0.3"
186+
leak_tracker_testing:
187+
dependency: transitive
188+
description:
189+
name: leak_tracker_testing
190+
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
191+
url: "https://pub.dev"
192+
source: hosted
193+
version: "3.0.1"
170194
lints:
171195
dependency: transitive
172196
description:
@@ -179,34 +203,34 @@ packages:
179203
dependency: transitive
180204
description:
181205
name: matcher
182-
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
206+
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
183207
url: "https://pub.dev"
184208
source: hosted
185-
version: "0.12.16"
209+
version: "0.12.16+1"
186210
material_color_utilities:
187211
dependency: transitive
188212
description:
189213
name: material_color_utilities
190-
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
214+
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
191215
url: "https://pub.dev"
192216
source: hosted
193-
version: "0.5.0"
217+
version: "0.8.0"
194218
meta:
195219
dependency: transitive
196220
description:
197221
name: meta
198-
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
222+
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
199223
url: "https://pub.dev"
200224
source: hosted
201-
version: "1.10.0"
225+
version: "1.12.0"
202226
path:
203227
dependency: transitive
204228
description:
205229
name: path
206-
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
230+
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
207231
url: "https://pub.dev"
208232
source: hosted
209-
version: "1.8.3"
233+
version: "1.9.0"
210234
plugin_platform_interface:
211235
dependency: transitive
212236
description:
@@ -264,10 +288,10 @@ packages:
264288
dependency: transitive
265289
description:
266290
name: test_api
267-
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
291+
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
268292
url: "https://pub.dev"
269293
source: hosted
270-
version: "0.6.1"
294+
version: "0.7.0"
271295
vector_math:
272296
dependency: transitive
273297
description:
@@ -276,14 +300,14 @@ packages:
276300
url: "https://pub.dev"
277301
source: hosted
278302
version: "2.1.4"
279-
web:
303+
vm_service:
280304
dependency: transitive
281305
description:
282-
name: web
283-
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
306+
name: vm_service
307+
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
284308
url: "https://pub.dev"
285309
source: hosted
286-
version: "0.3.0"
310+
version: "14.2.1"
287311
sdks:
288-
dart: ">=3.2.3 <4.0.0"
289-
flutter: ">=3.3.0"
312+
dart: ">=3.3.0 <4.0.0"
313+
flutter: ">=3.18.0-18.0.pre.54"

lib/src/firestore_pagination.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class FirestorePagination extends StatefulWidget {
7474
///
7575
/// The builder is passed the build context, snapshot of the document and
7676
/// index of the item in the list.
77-
final Widget Function(BuildContext, DocumentSnapshot, int) itemBuilder;
77+
final Widget Function(BuildContext, List<DocumentSnapshot>, int) itemBuilder;
7878

7979
/// The builder to use to render the separator.
8080
///

lib/src/realtime_db_pagination.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class RealtimeDBPagination extends StatefulWidget {
7676
///
7777
/// The builder is passed the build context, snapshot of data and index of
7878
/// the item in the list.
79-
final Widget Function(BuildContext, DataSnapshot, int) itemBuilder;
79+
final Widget Function(BuildContext, List<DataSnapshot>, int) itemBuilder;
8080

8181
/// The field to use to sort the data. Give the same value as the field
8282
/// used to order the data in the query.

lib/src/widgets/views/build_pagination.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BuildPagination<T> extends StatelessWidget {
3636
final List<T> items;
3737

3838
/// The builder to use to render the items.
39-
final Widget Function(BuildContext, T, int) itemBuilder;
39+
final Widget Function(BuildContext, List<T>, int) itemBuilder;
4040

4141
/// The builder to use to render the separator.
4242
///
@@ -91,7 +91,7 @@ class BuildPagination<T> extends StatelessWidget {
9191
itemBuilder: (BuildContext context, int index) {
9292
if (index >= items.length) return bottomLoader;
9393

94-
return itemBuilder(context, items[index], index);
94+
return itemBuilder(context, items, index);
9595
},
9696
separatorBuilder: separatorBuilder,
9797
);
@@ -108,7 +108,7 @@ class BuildPagination<T> extends StatelessWidget {
108108
itemBuilder: (BuildContext context, int index) {
109109
if (index >= items.length) return bottomLoader;
110110

111-
return itemBuilder(context, items[index], index);
111+
return itemBuilder(context, items, index);
112112
},
113113
gridDelegate: gridDelegate,
114114
);
@@ -135,7 +135,7 @@ class BuildPagination<T> extends StatelessWidget {
135135
(int index) {
136136
if (index >= items.length) return bottomLoader;
137137

138-
return itemBuilder(context, items[index], index);
138+
return itemBuilder(context, items, index);
139139
},
140140
),
141141
),

0 commit comments

Comments
 (0)