Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/firebase-ui-firestore.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final usersQuery = FirebaseFirestore.instance.collection('users').orderBy('name'

FirestoreListView<Map<String, dynamic>>(
query: usersQuery,
itemBuilder: (context, snapshot) {
itemBuilder: (context, snapshot, index) {
Map<String, dynamic> user = snapshot.data();

return Text('User name is ${user['name']}');
Expand Down Expand Up @@ -109,7 +109,7 @@ final usersQuery = FirebaseFirestore.instance.collection('users')

FirestoreListView<User>(
query: usersQuery,
itemBuilder: (context, snapshot) {
itemBuilder: (context, snapshot, index) {
// Data is now typed!
User user = snapshot.data();

Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_ui_firestore/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FirebaseUIFirestoreExample extends StatelessWidget {
body: FirestoreListView<User>(
query: collection,
padding: const EdgeInsets.all(8.0),
itemBuilder: (context, snapshot) {
itemBuilder: (context, snapshot, index) {
final user = snapshot.data();
return Column(
children: [
Expand Down
11 changes: 6 additions & 5 deletions packages/firebase_ui_firestore/lib/src/query_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ class _Sentinel {
typedef FirestoreItemBuilder<Document> = Widget Function(
BuildContext context,
QueryDocumentSnapshot<Document> doc,
int index,
);

/// A type representing the function passed to [FirestoreListView] for its `loadingBuilder`.
Expand Down Expand Up @@ -419,7 +420,7 @@ typedef FirestoreEmptyBuilder = Widget Function(BuildContext context);
/// ```dart
/// FirestoreListView<Movie>(
/// query: moviesCollection.orderBy('title'),
/// itemBuilder: (context, snapshot) {
/// itemBuilder: (context, snapshot, index) {
/// Movie movie = snapshot.data();
/// return Text(movie.title);
/// },
Expand Down Expand Up @@ -504,7 +505,7 @@ class FirestoreListView<Document> extends FirestoreQueryBuilder<Document> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
itemBuilder(context, doc),
itemBuilder(context, doc, index),
if (isLastItem && snapshot.hasMore)
fetchingIndicatorBuilder?.call(context) ??
const Padding(
Expand All @@ -521,7 +522,7 @@ class FirestoreListView<Document> extends FirestoreQueryBuilder<Document> {
],
),
)
: itemBuilder(context, doc);
: itemBuilder(context, doc, index);
},
scrollDirection: scrollDirection,
reverse: reverse,
Expand Down Expand Up @@ -615,7 +616,7 @@ class FirestoreListView<Document> extends FirestoreQueryBuilder<Document> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
itemBuilder(context, doc),
itemBuilder(context, doc, index),
if (isLastItem && snapshot.hasMore)
fetchingIndicatorBuilder?.call(context) ??
const Padding(
Expand All @@ -632,7 +633,7 @@ class FirestoreListView<Document> extends FirestoreQueryBuilder<Document> {
],
),
)
: itemBuilder(context, doc);
: itemBuilder(context, doc, index);
},
separatorBuilder: separatorBuilder,
scrollDirection: scrollDirection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ void main() {
body: FirestoreListView<Map>(
query: collection.orderBy('value'),
loadingBuilder: (context) => const Text('loading...'),
itemBuilder: (context, snapshot) => throw UnimplementedError(),
itemBuilder: (context, snapshot, index) =>
throw UnimplementedError(),
),
),
),
Expand All @@ -84,7 +85,8 @@ void main() {
home: Scaffold(
body: FirestoreListView<Map>(
query: collection.orderBy('value'),
itemBuilder: (context, snapshot) => throw UnimplementedError(),
itemBuilder: (context, snapshot, index) =>
throw UnimplementedError(),
),
),
),
Expand All @@ -105,7 +107,8 @@ void main() {
body: FirestoreListView<Map>(
query: collection,
cacheExtent: 0,
itemBuilder: (context, snapshot) => throw UnimplementedError(),
itemBuilder: (context, snapshot, index) =>
throw UnimplementedError(),
),
),
),
Expand Down Expand Up @@ -144,7 +147,7 @@ void main() {
cacheExtent: 0,
pageSize: 5,
itemExtent: size,
itemBuilder: (context, snapshot) {
itemBuilder: (context, snapshot, index) {
final v = snapshot.data()['value'] as int;

return Container(
Expand Down Expand Up @@ -208,6 +211,7 @@ class ListViewBuilderSpy<T> extends Mock {
Widget call(
BuildContext? context,
T? snapshot,
int? index,
) {
return super.noSuchMethod(
Invocation.method(#call, [context, snapshot]),
Expand Down