Paginates appwrite collections.

Overview

Appwrite Pagination

Provides paginatation functionality on appwrite collections.

  • Option to cache or paginate documents of a collection.
  • Sort documents by orderType and orderAttributes.
  • Provides collection start and end indicators.
  • Comes with a dedicated Widget to allow for finer control over paginated collections.

Pagination

Provides the bare minimum for pagination functionality of an appwrite collection. This object can be used with any widget for less restrictive usage otherwise, using a PaginationWidget can provide the typical functionality required for pagination such as start/end callbacks and its own scroll controller with managed state.

Usage

final pagination = Pagination(
  cached: true,
  documentsPerPage: 2,
  collectionId: 'messages',
  orderAttributes: ['text'],
  orderTypes: ['DESC'],
  database: Databases(client, databaseId: 'main'),
  onStartCallback: (documents) => print('Start'),
  onEndCallback: (documents) => print('End'),
);

PaginationWidget

A complimentary widget to be used with a Pagination instance. Provides its child widget access to its internal scroll controller with options to specify callbacks when reaching the start/end of a collection.

Usage

PaginationWidget(
    pagination: pagination,
    child: (controller) => ListView.builder(
      itemCount: pagination.documentList.length,
      shrinkWrap: true,
      itemBuilder: (context, index) =>
          Text(pagination.documentList[index].data['text']),
    ),
  ),

Full Example

import 'package:appwrite/appwrite.dart';
import 'package:flutter/material.dart';
import 'package:appwrite_pagination_flutter/appwrite_pagination_flutter.dart';

main() => runApp(const App());

final client = Client(endPoint: 'http://localhost/v1')..setProject('main');
final pages = Pagination(
  // cached: false,
  itemsPerPage: 1,
  collectionId: 'messages',
  orderAttributes: ['text'],
  orderTypes: ['ASC'],
  database: Databases(client, databaseId: 'main'),
);

class App extends StatelessWidget {
  const App({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: Home());
  }
}

class Home extends StatefulWidget {
  const Home({super.key});

  @override
  HomeState createState() => HomeState();
}

class HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Home')),
      body: Column(
        children: [
          ListView.builder(
            shrinkWrap: true,
            itemCount: pages.documentList.length,
            itemBuilder: (context, index) =>
                Text(pages.documentList[index].data['text']),
          ),
          Text('atStart: ${pages.atStart}'),
          Text('atEnd: ${pages.atEnd}'),
          ElevatedButton(
              onPressed: () async {
                await pages.get('before');
                setState(() {});
              },
              child: const Text('Before')),
          ElevatedButton(
              onPressed: () async {
                await pages.get('after');
                setState(() {});
              },
              child: const Text('After')),
          ElevatedButton(
              onPressed: () async {
                pages.clear();
                setState(() {});
              },
              child: const Text('Clear')),
          ElevatedButton(
              onPressed: () async {
                pages.sort(orderAttributes: ['text'], orderTypes: ['DESC']);
                setState(() {});
              },
              child: const Text('Sort DESC')),
          ElevatedButton(
              onPressed: () async {
                pages.sort(orderAttributes: ['text'], orderTypes: ['ASC']);
                setState(() {});
              },
              child: const Text('Sort ASC')),
        ],
      ),
    );
  }
}
You might also like...

Making Appwrite Authentication Easy

FlAppwrite Account Kit A Flutter wrapper for Appwrite's Accounts service, makes it easy to use manage authentication and account features. Under devel

Jan 8, 2023

A demo built with Flutter and Appwrite backend for Hacktoberfest 2021.

A demo built with Flutter and Appwrite backend for Hacktoberfest 2021.

Artistry: Appwrite - Flutter Demo 💻 Artistry is a demo app built with flutter and Appwrite backend for Hacktoberfest 2021, that demonstrates how to p

Dec 16, 2022

A basic demo example for integrating between Appwrite & Flutter 💙

A basic demo example for integrating between Appwrite & Flutter 💙

🔖 Todo With Flutter A simple todo app built with Flutter and Appwrite 🎬 Getting Started Appwrite is an end-to-end backend server for Web, Mobile, Na

Dec 15, 2022

A basic demo example for integrating between Appwrite & Flutter 💙

A basic demo example for integrating between Appwrite & Flutter 💙

🔖 Quiz With Flutter A simple Quiz App built with Flutter and Appwrite 🎬 Getting Started 🤘 Install Appwrite Follow our simple Installation Guide to

Nov 22, 2022

Appwrite is a secure end-to-end backend server for Web, Mobile, and Flutter developers that is packaged as a set of Docker containers for easy deployment 🚀

Appwrite is a secure end-to-end backend server for Web, Mobile, and Flutter developers that is packaged as a set of Docker containers for easy deployment 🚀

A complete backend solution for your [Flutter / Vue / Angular / React / iOS / Android / *ANY OTHER*] app Appwrite 0.12 has been released! Learn what's

Jan 3, 2023

A Netflix clone built with @appwrite + @flutter

A Netflix clone built with @appwrite + @flutter

Almost Netflix - Flutter Requirements Before using this project, you will need to have Appwrite instance with Almost Netflix project ready. You can vi

Dec 26, 2022

Simple quiz app built with Appwrite + Flutter + Codemagic

Simple quiz app built with Appwrite + Flutter + Codemagic

Flutter Festival Kathmandu Quiz App A quiz app for the Flutter Festival Kathmandu built with Flutter Web on frontend and Appwrite on backend. Live Pre

Oct 22, 2022

Notes App created with Flutter and Appwrite.

Notes App created with Flutter and Appwrite.

Note Keeper A Flutter + AppWrite Project Note Keeper is a Note Creater App build with Flutter backed by AppWrite (An Open-Source Backend Server) 💡 Fu

Oct 22, 2022
Owner
Pa Ka
Based in Aotearoa (New Zealand). Exclusively developing in Dart 🎯 under the Flutter framework.
Pa Ka
A basic demo example for integrating between Appwrite & Flutter 💙

?? Quiz With Flutter A simple Quiz App built with Flutter and Appwrite ?? Getting Started ?? Install Appwrite Follow our simple Installation Guide to

Appwrite 35 Nov 22, 2022
A Netflix clone built with @appwrite + @flutter

Almost Netflix - Flutter Requirements Before using this project, you will need to have Appwrite instance with Almost Netflix project ready. You can vi

Appwrite 49 Dec 26, 2022
Simple examples that help you get started with Appwrite + Dart (=❤️) as an Appwrite server-side integration.

Playground for Dart Simple examples that help you get started with Appwrite + Dart (= ❤️ ) This is Appwrite server side integration with Dart. For Flu

Appwrite 31 Nov 22, 2022
Code collections for MI2S Dart lang study group.

MI2S Dart Language Study Group Code collections for MI2S Dart lang study group. Get started Install flutter (which contains the dart SDK). Clone the r

Michael Shih 2 Nov 10, 2021
Functional extensions to Dart collections.

collection_ext A set of extension methods for Dart collections, designed for the purpose of making it easier to write concise, functional-programming-

Yingxin Wu 7 Nov 21, 2022
Contains utility functions and classes in the style of dart:collection to make working with collections easier

The collection package for Dart contains a number of separate libraries with utility functions and classes that makes working with collections easier.

Dart 273 Dec 27, 2022
A port of kotlin-stdlib for Dart/Flutter including immutable collections (KtList, KtMap, KtSet) and other packages

kt.dart This project is a port of Kotlin's Kotlin Standard library for Dart/Flutter projects. It's a useful addition to dart:core and includes collect

Pascal Welsch 460 Jan 9, 2023
Immutable Dart collections via the builder pattern.

Built Collections for Dart Introduction Built Collections are immutable collections using the builder pattern. Each of the core SDK collections is spl

Google 250 Dec 20, 2022
A collections of packages providing additional functionality for working with bloc

Bloc Extensions A collections of packages providing additional functionality for working with bloc. Index Packages Bloc Hooks Action Blocs Contributin

Aljoscha Grebe 2 Apr 19, 2022
A basic demo example for integrating between Appwrite & Flutter 💙

?? Quiz With Flutter A simple Quiz App built with Flutter and Appwrite ?? Getting Started ?? Install Appwrite Follow our simple Installation Guide to

Appwrite 35 Nov 22, 2022