opinionated_pagination 1.1.0+1 copy "opinionated_pagination: ^1.1.0+1" to clipboard
opinionated_pagination: ^1.1.0+1 copied to clipboard

An ellipsis pagination solution for Flutter. Designed with Riverpod, but should work with any state management solution.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:opinionated_pagination/opinionated_pagination.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Opinionated Pagination Demo',
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  const Home({Key? key}) : super(key: key);

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

class _HomeState extends State<Home> {
  int paginationPage = 0;
  final int limit = 5;
  final int itemCount = 120;

  @override
  Widget build(BuildContext context) {
    final _pageGroupEnd = (paginationPage + 1) * limit;
    final _pageGroupStart = _pageGroupEnd - (limit - 1);
    return Scaffold(
      appBar: AppBar(
        title: Text('Opinionated Pagination Example'),
      ),
      body: Container(
        padding: const EdgeInsets.only(top: 10.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text(
                    'Showing $_pageGroupStart to ${_pageGroupEnd > itemCount ? itemCount : _pageGroupEnd} of $itemCount'),
              ],
            ),
            Divider(height: 22.0, thickness: 1.0, color: Colors.grey.shade300),
            OpinionatedPagination(
              pageNumber: paginationPage,
              totalItems: itemCount,
              skip: paginationPage,
              limit: limit,
              onPageChanged: (int? i) {
                if (i != null) {
                  setState(() {
                    paginationPage = i;
                  });
                }
              },
            ),
          ],
        ),
      ),
    );
  }
}
7
likes
150
points
11
downloads

Publisher

verified publisherbroadwood.dev

Weekly Downloads

An ellipsis pagination solution for Flutter. Designed with Riverpod, but should work with any state management solution.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on opinionated_pagination