fire_pagination 0.0.1 copy "fire_pagination: ^0.0.1" to clipboard
fire_pagination: ^0.0.1 copied to clipboard

unlisted

Widget to implement pagination, works with Android and Web. Paginated ListView has two required parameters itemBuilder and service. The itemBuilder parameter builds widgets using the items/data in the [...]

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fire_pagination/fire_pagination.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: PagedListView(
            itemBuilder: (item, index) {
              return Row(
                children: [
                  Text('$index'),
                  SizedBox(width: 20),
                  Text('$item'),
                ],
              );
            },
            service: MyService1()));
  }
}

class MyService1 extends PaginationService {
  @override
  Future<List> getData([lastFetched]) async {
    return List<int>.generate(30, (int index) => index * index);
  }
}

/// This example shows how to use [PagedListView] with [Firestore].
/// The optional parameter [lastFetched] will be the cursor to implement
/// pagination. Function [getData] fetches data from this point.
//class MyService3 extends PaginationService {
//  String collection = 'someCollection';
//  int pageSize = 20;
//
//  @override
//  Future<List> getData([dynamic lastFetched = 0]) async {
//    print('service fetching');
//    return await lastFetched == 0
//        ? FirebaseFirestore.instance
//            .collection(collection)
//            .orderBy('a')
//            .limit(pageSize)
//            .get()
//            .then((value) {
//            return value.docs.toList();
//          })
//        : FirebaseFirestore.instance
//            .collection(collection)
//            .orderBy('a')
//            .limit(pageSize)
//            .startAfterDocument(lastFetched)
//            .get()
//            .then((value) {
//            return value.docs.toList();
//          });
//  }
//}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

Widget to implement pagination, works with Android and Web. Paginated ListView has two required parameters itemBuilder and service. The itemBuilder parameter builds widgets using the items/data in the list. The service parameter accepts an Object which extends PaginationService, this provides the getData function to fetch data into the list on demand.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

equatable, flutter, flutter_riverpod

More

Packages that depend on fire_pagination