Skip to content

A flutter package to simplify pagination with firestore data ๐Ÿ—ƒ

License

Notifications You must be signed in to change notification settings

mudi256/paginate_firestore

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

94 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Pagination in Firestore

All Contributors

pub package style: effective dart License: MIT

Setup

Use the same setup used for cloud_firestore package (or follow this).

Usage

In your pubspec.yaml

dependencies:
  paginate_firestore: # latest version

Import it

import 'package:paginate_firestore/paginate_firestore.dart';

Implement it

      PaginateFirestore(
        //item builder type is compulsory.
        itemBuilder: (context, documentSnapshots, index) {
          final data = documentSnapshots[index].data() as Map?;
          return ListTile(
            leading: CircleAvatar(child: Icon(Icons.person)),
            title: data == null ? Text('Error in data') : Text(data['name']),
            subtitle: Text(documentSnapshots[index].id),
          );
        },
        // orderBy is compulsory to enable pagination
        query: FirebaseFirestore.instance.collection('users').orderBy('name'),
        //Change types accordingly
        itemBuilderType: PaginateBuilderType.listView,
        // to fetch real-time data
        isLive: true,
      ),

To use with listeners:

      PaginateRefreshedChangeListener refreshChangeListener = PaginateRefreshedChangeListener();

      RefreshIndicator(
        child: PaginateFirestore(
          itemBuilder: (context, documentSnapshots, index) => ListTile(
            leading: CircleAvatar(child: Icon(Icons.person)),
            title: Text(documentSnapshots[index].data()['name']),
            subtitle: Text(documentSnapshots[index].id),
          ),
          // orderBy is compulsary to enable pagination
          query: Firestore.instance.collection('users').orderBy('name'),
          listeners: [
            refreshChangeListener,
          ],
        ),
        onRefresh: () async {
          refreshChangeListener.refreshed = true;
        },
      )

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue. If you fixed a bug or implemented a feature, please send a pull request.

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Contributors โœจ

Thanks goes to these wonderful people:


Adam Dupuis

๐Ÿ’ป

Gautham

๐Ÿ’ป

Hafeez Ahmed

๐Ÿ’ป

Claudemir Casa

๐Ÿ’ป

Nikhil27bYt

๐Ÿ“–

Ferri Sutanto

๐Ÿ’ป

jslattery26

๐Ÿ’ป

garrettApproachableGeek

๐Ÿ’ป

Sua Mรบsica

๐Ÿ’ป

Austin Nelson

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

About

A flutter package to simplify pagination with firestore data ๐Ÿ—ƒ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 36.5%
  • C++ 29.9%
  • CMake 14.1%
  • Ruby 8.2%
  • HTML 7.0%
  • Swift 2.5%
  • Other 1.8%