vedartm / paginate_firestore

A flutter package to simplify pagination with firestore data 🗃
https://pub.dev/packages/paginate_firestore
MIT License
113 stars 136 forks source link

Listener example is not working #47

Closed Samson11 closed 3 years ago

Samson11 commented 3 years ago

Listener example is not working I am receiving syntax errors in Android Studio and will it be able to update whenever a collection changes with pulling a loader

vedartm commented 3 years ago

Could you please share the code you tried @Samson11 ?

Sreejithns2002 commented 3 years ago
RefreshIndicator(
            child: PaginateFirestore(
              itemBuilder: (index, context, documentSnapshot) {
                return CommentCard(Comment.fromData(documentSnapshot.data()));
              },
              query: widget.commentRepository.getQuery(),
              itemBuilderType: PaginateBuilderType.listView,
              listeners: [refreshNotifier],
            ),
            onRefresh: () async {
              print('refressed');
              refreshNotifier.refreshed = true;
            },
          ),
class RefreshNotifier extends ChangeNotifier {
  bool _refreshed;

  bool get refreshed => _refreshed;

  set refreshed(bool value) {
    _refreshed = value;
    notifyListeners();
  }
}

There must be something wrong with my implementation but the readme or the example doesn't have this functionality code. @excogitatr Please say how this is done

Sreejithns2002 commented 3 years ago
import 'package:paginate_firestore/bloc/pagination_listeners.dart';
.
.

PaginateRefreshedChangeListener paginateNotifier = PaginateRefreshedChangeListener();
.
.

RefreshIndicator(
            child: PaginateFirestore(
              itemBuilder: (index, context, documentSnapshot) {
                return CommentCard(Comment.fromData(documentSnapshot.data()));
              },
              query: widget.commentRepository.getQuery(),
              itemBuilderType: PaginateBuilderType.listView,
              listeners: [paginateNotifier],
            ),
            onRefresh: () async {
              paginateNotifier.refreshed = true;
            },
          ),

I figured It out. @excogitatr I think you should make a barrel file otherwise how could people know you should import bloc/pagination_listener.dart and use the PaginateRefreshedChangeListener.

vedartm commented 3 years ago

Agreed @Sreejithns2002 . Hope this fixes you issue @Samson11 as well.