vedartm / paginate_firestore Goto Github PK
View Code? Open in Web Editor NEWA flutter package to simplify pagination with firestore data ๐
Home Page: https://pub.dev/packages/paginate_firestore
License: MIT License
A flutter package to simplify pagination with firestore data ๐
Home Page: https://pub.dev/packages/paginate_firestore
License: MIT License
Please support cloud_firestore 2.0.0
Thanks for the latest update! Support of stream is big help for me :)
By the way, I found a minor documentation bug on pub.dev.
I'd be happy to check it out!
Github(latest)
PaginateFirestore(
itemBuilderType: PaginateBuilderType.listView, // listview and gridview
itemBuilder: (index, context, documentSnapshot) => ListTile(
leading: CircleAvatar(child: Icon(Icons.person)),
title: Text(documentSnapshot.data()['name']),
subtitle: Text(documentSnapshot.documentID),
),
// orderBy is compulsary to enable pagination
query: Firestore.instance.collection('users').orderBy('name'),
isLive: true // to fetch real-time data
)
pub.dev
PaginateFirestore(
itemBuilder: (context, documentSnapshot) => ListTile(
leading: CircleAvatar(child: Icon(Icons.person)),
title: Text(documentSnapshot.data['name']),
subtitle: Text(documentSnapshot.documentID),
),
// orderBy is compulsary to enable pagination
query: Firestore.instance.collection('users').orderBy('name'),
isLive: true // to fetch real-time data
)
Kindly add the swipe to refresh or stream provider in order to get the latest document if any document is added to the collection.
Can we control the limit of items per page? if so, how?
How to know when is fetching more documents, like a bool variable, to show some CircularProgressIndicator with "loading more data" to the user?
Could you expose the set of the ListVIew controller?
Thanks :)
I have used this package for displaying the contents of my firestore collection. But I also have implemented filters such as the where
clause is changed on the basis of the filter the user has chosen. I tried the store my query in a variable and change it but even after changing the query variable, I am not able to bring the filtered data. Is there any way that I can rebuild the whole PaginatedFirestore widget or any other approach that would help? Thanks.
I'd like to add a widget at the very bottom of the list (that scrolls with the list). However, in order to do this, I need to know the total number of items on the list. How can I do this ? Thanks.
Hello,
from changelog of 0.2.0 version
Added support for Search and Refresh listeners
but when I'm looking on the implementation we throw UnimplementedError
@override
void initState() {
_scrollController = widget.scrollController ?? ScrollController();
if (widget.listeners != null) {
for (var listener in widget.listeners) {
if (listener is PaginateRefreshedChangeListener) {
listener.addListener(() {
if (listener.refreshed) {
refresh();
}
});
} else if (listener is PaginateSearchChangeListener) {
listener.addListener(() {
throw UnimplementedError();
});
}
}
}
so should we implement SearchChangeListener ? if yes can you please provide sample
Thanks
can you provide us a method to switch between ListView to GridView based on user click on button
Hello,
I'm implementing a simple chat using firestore, and I need a pagination. and this library sounds amazing, it handles loaders, pagination, search, all the stuff. Thanks!
However, I want to add a new document to the collection. the new document is not appended to the list view but it's added in the collection in firestore. and it works if I refresh the listview.
Is there any good way to add elements without refreshing the list?
Hi i have used bool variable, setState, changenotifier. None of them worked . Please let me know if it is possible ?
Thank You
Hello,
I am trying to implement a search bar, and I need to change the query for every new search.
Problem: The list does not refresh itself when I am changing the query using a setState.
Is it supposed to work that way? Do you recommend another solution ?
Thank you for your help,
Benjamin
Hello, How do I use the search function?
I try with filterTerm but it returns a search and when I try to search for something else it is no longer possible, because the list was limited to the previous search.
The only solution I have found is refreshed all the time, but I don't think it is optimal
Hi
Thanks for your package. It saves a lot of my time ๐
Btw, I noticed that when using isLive
option as true
, the stream is always active even we moved into another screen.
We need to capture the StreamSubscription
from this line https://github.com/excogitatr/paginate_firestore/blob/master/lib/bloc/pagination_cubit.dart#L86 and cancel()
on dispose
.
Something like this
List<StreamSubscription<QuerySnapshot>>() streams = List<StreamSubscription<QuerySnapshot>>();
...
_getLiveDocuments() {
...
StreamSubscription listener = localQuery.snapshots().listen((querySnapshot) {
_emitPaginatedState(
querySnapshot.docs,
previousList:
loadedState.documentSnapshots as List<QueryDocumentSnapshot>,
);
});
}
streams.add(listeners);
}
...
streams.forEach((listener) => listener.cancel());
Thanks
How can I refresh PaginateFirestore from start?
It would be good if could animate data that fetches in real-time.
widget to show before the list
I am using the widget PaginateFirestore. It fetches data but the list is not scrolling. here is code.
@override
Widget build(BuildContext context) {
return BlocProvider<TalentFavCubit>(
create: (context) => TalentFavCubit(),
child: SafeArea(
child: Scaffold(
body: Padding(
padding: const EdgeInsets.all(20.0),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text('Talent Screen 1 home search'),
// _retrieveAllDocs,
_retrieveData,
],
),
),
),
),
),
);
}
Widget get _retrieveData => PaginateFirestore(
scrollDirection: Axis.vertical,
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilderType: PaginateBuilderType.listView,
query: FirebaseRepo.instance.fetchWorkerFormFieldsData(),
itemBuilder: (index, context, documentSnapshot) {
var data = documentSnapshot.data();
return theUserInfo(data);
},
isLive: true,
);
Widget theUserInfo(var data) {
TalentHireFavModel userData =
TalentHireFavModel.fromMap(data);
return Card(
child: Column(
children: <Widget>[
Text(userData.categories),
SizedBox(height: 100.0,),
Text(userData.skills),
Text(userData.phoneNo),
Text(userData.hourlyRate),
Text(userData.professionalOverview),
Text(userData.skills),
Text(userData.expert),
//_iconButton(userData.uid),
],
),
);
}
```}
PaginateRefreshedChangeListener is not working. Vscode states it is an undefined class
How retrieve a subcollection? The example just show a simple query.
Can I define how many items I want to add on one page?
Right now you can't refresh when emptyDisplay is shown. This is because emptyDisplay isn't a child of a Scrollable.
I have solved it like this but it would be nice if this was the default behaviour.
RefreshIndicator(
child: PaginateFirestore(
...
emptyDisplay: LayoutBuilder(
builder: (ctx, constraints) => SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Container(
height: constraints.maxHeight,
child: EmptyDisplay(),
),
),
),
),
);
Thanks for a great package!
Hi,
any plan to support cache query ? as you know we cannot imagine usage of firestore without caching for most of use case, just close and open the app will trigger new docs read if no local cache configured
Because every version of paginate_firestore depends on flutter_bloc ^4.0.0 and project depends on flutter_bloc ^5.0.1, paginate_firestore is forbidden.
So, because project depends on paginate_firestore ^0.1.1, version solving failed.
pub get failed (1; So, because project depends on paginate_firestore ^0.1.1, version solving failed.)
Thank you for this amazing library. Just wanna know what is the proper method to cast documentSnapshot to my Model i.e Product.
tried this inside item itemBuilder, but doesn't work.
Product products =documentSnapshot.data() as Product;
Error is _InternalLinkedHashMap<String, dynamic>' is not a subtype of type documentSnapshot.data.
Update: Ok, seems am doing it wrong. Can anyone help me mapping the snapshot data to an object
Hey I want list to navigate to data of that particular item how can I do that please guide me
Could you add an option to use a collection stream with this widget?
Would be awesome to have an index in the itemBuilder function!
Please I need to change the default no document found message when there are no documents found. I have used:
`if(snapshot.data().isEmpty || snapshot.data().length < 1 || !snapshot.data().isNotEmpty){
return Container(
margin: EdgeInsets.only(top: 170),
child: NoDataAvailable(
message: 'No Video posts Yet',
),
);
}`
but i still get the no document found message
hello ..
I love your packages but my project need to tab .
when I use this package on NestedScrollView but scroll with SliverAppBar not working .
if I fixed that by SliverChildListDelegate or any widget has scroll I have another problem with paginate firestore it's get all document in once .
how I fixed that ?
thank u ...
How to use with GridView.builder?
thank you.
Update list/grid-view when change query.
I use setState to update query but list/grid-view not update.
In my code ListView is a perfect run but GridView Container size is not changeble so please help me or add new options to change GridView design
With Flutter 2.0 released today, everyone is updating to cloud_firestore: 1.0, but this package isn't compatible.
Thank you for contributing your excellent package.
Would it be possible to scroll automatically according to the given timer setting value?
Except basic ui, I want to use this package for upper screen on youtube screen and lower paginated firestore text data.
Thanks!
Is it possible to show the header widget even when no documents are found in the query?
Hi how can you remove an item from the list?, currently i use Slidable (https://pub.dev/packages/flutter_slidable) , i remove from firebase the document but it doesnt remove from list view
Is it possible to use this widget inside a ListView? It seems that all elements are loaded when I put it in a ListView.
Hi,
Would it be possible for you to add a feature that allows us to use a List of DocumentSnapshot instead of the Query type ?
Thanks
Jennie
Could you please add options to add scrolling a header and a footer?
Thanks
Firestore plugin is updated to 0.14 and all things changed please bring a new version of your package
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
Hi @excogitatr
it's possible to support List<query>
to WA Firestore 10 limit when using IN operator
ref : https://ncona.com/2021/01/dealing-with-firestore-10-limit-with-in-operator
this will save the live of anyone use firestore !!!
As we know that pagination delivers data in chunks. How many documents are received in first instance and then in upcoming instances?
Hi,
Firestore document has a field called 'category' , i need to filter only those category field results ex: 'category' == 'men' or category == 'women'. So how do i filter documents based on these inputs . Can u give example code ?
Hi
I would like to have a status about this package, so @excogitatr @adamdupuis @claudemircasa @imhafeez @GauthamAsir all others contributors if it's possible to have answer of those questions :
Thank you for your understanding
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.