flutter_easy_paginate 1.0.1 copy "flutter_easy_paginate: ^1.0.1" to clipboard
flutter_easy_paginate: ^1.0.1 copied to clipboard

A Flutter package that simplifies pagination for various scrollable widgets like ListView, GridView, and Column. It provides seamless data fetching with customizable loader widgets and supports both v [...]

Flutter Easy Paginate #

Flutter Easy Paginate Platform License

A Flutter package for easy pagination, allowing seamless integration with various scrollable widgets like ListView, GridView, Column, etc.

Features #

  • Seamless Pagination: Automatically fetch the next page of data when reaching the end of the scroll.
  • Customizable Loader: Display a default loader or provide your own custom loader widget.
  • Flexible Scroll Direction: Support for both vertical and horizontal scrolling.

Installation #

Add the following line to your pubspec.yaml:

dependencies:
  flutter_easy_paginate: ^1.0.1

Usage #

import 'package:flutter/material.dart';
import 'package:flutter_easy_paginate/paginate.dart';

class MyListView extends StatefulWidget {
  @override
  _MyListViewState createState() => _MyListViewState();
}

class _MyListViewState extends State<MyListView> {
  final List<String> _items = List.generate(20, (index) => 'Item $index');
  final ScrollController _scrollController = ScrollController();
  int _page = 1;

  Future<void> _fetchNextPage() async {
    // Simulate API call
    await Future.delayed(Duration(seconds: 2));

    setState(() {
      _items.addAll(List.generate(20, (index) => 'Item ${_items.length + index}'));
      _page++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Paginate Example'),
      ),
      body: Paginate(
        scrollController: _scrollController,
        onNextPage: _fetchNextPage,
        child: ListView.builder(
          controller: _scrollController,
          itemCount: _items.length,
          itemBuilder: (context, index) {
            return ListTile(
              title: Text(_items[index]),
            );
          },
        ),
      ),
    );
  }
}

Custom Loader #

Paginate(
  scrollController: _scrollController,
  onNextPage: _fetchNextPage,
  loader: Center(
    child: CircularProgressIndicator(
      valueColor: AlwaysStoppedAnimation<Color>(Colors.red),
    ),
  ),
  child: ListView.builder(
    controller: _scrollController,
    itemCount: _items.length,
    itemBuilder: (context, index) {
      return ListTile(
        title: Text(_items[index]),
      );
    },
  ),
);
4
likes
0
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that simplifies pagination for various scrollable widgets like ListView, GridView, and Column. It provides seamless data fetching with customizable loader widgets and supports both vertical and horizontal scrolling.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_easy_paginate