This package helps in the bagging process when receiving data from the Internet, reduces the number of requests, and get data that fits on one page.

Support

Android IOS Web

Features

A Pagination Library for Flutter (with Web Support).

Installation

To install flutter_pagination_data, add the following line to your pubspec.yaml file:

dependencies:
  flutter_pagination_data: ^1.0.0

Import the package and use it in your Flutter App.


import 'package:flutter_pagination_data/flutter_pagination_data.dart';


Usage

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

  @override
  Widget build(BuildContext context) {
    return CustomPagination<NewsData>(
      separatorWidget: SizedBox(
        height: 10.0,
      ),
      itemBuilder: (BuildContext context, item) {
        return ListTile(
          title:
          Text(item.title),
          subtitle: Text(item.description),
          leading: IconButton(
            icon: Icon(Icons.more_horiz),
            onPressed: () => print(item.id),
          ),
          onTap: () => print(item.source),
          trailing: Icon(
            Icons.add,
          ),
        );
      },
      fetchMethod: fetchMethod,
      onError: (error) => Center(
        child: Text('Error'),
      ),
      onEmpty: Center(
        child: Text('Empty'),
      ),
    );
  }
}

Properties

itemBuilder Widget Function null items list to retrive it
onError Widget Function null show widget when error.
onEmpty Widget null show widget when empty.
separatorWidget Widget null space between widgets.
onPageLoading Widget Circle Progress show widget when page loading.
onLoading Widget Circle show widget when loading new item.
fetchMethod PaginationBuilder null method to fetch listed data.
initialData List null initial data to show it.
scrollDirection Axis Vertical scroll axis , horiz | vertical .
physics ScrollPhysics null need to scroll or not.
shrinkWrap bool true shrinkWrap items.
isGridView bool false support show data as gridView.
crossAxisCount int 1 crossAxisCount when use gridView.
mainAxisExtent double 100 item height when use gridView.
mainAxisSpacing double 10.0 main axis space when use gridView.
crossAxisSpacing double 10.0 cross axis space when use gridView.