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

`AutoPaginatedList` is a Flutter widget that simplifies infinite scrolling and pagination using `Provider` for state management. It automatically fetches more data as the user scrolls, supports custom [...]

PaginatedListView is a Flutter widget that simplifies infinite scrolling and pagination with Provider-based state management. It automatically loads more data as the user scrolls, supports custom loading, error, and empty states, and provides flexible configuration options for a seamless experience.

Features #

✅ Automatic Pagination – Fetches more data as the user scrolls. ✅ Provider-Based State Management – Efficient and optimized with ChangeNotifier. ✅ Customizable UI – Supports loading, error, and empty state widgets. ✅ Smooth Performance – Scroll handling optimized with a ScrollController. ✅ Flexible Configuration – Customize page size, separators, initial page, and physics. ✅ Easy Integration – Just pass your data-fetching function and item builder!

Getting started #

Flutter: Ensure that you have Flutter 2.0 or later installed on your machine.

Provider: This package uses Provider for state management, so make sure to include it in your pubspec.yaml.

Usage #

To use this package, simply integrate it into your Flutter project and provide a function to fetch paginated data. The package handles infinite scrolling, loading indicators, error handling, and empty states out of the box.

You can customize the appearance using optional widgets for loading, error, and empty states. Additionally, separators can be added between list items.

For a complete implementation, check the /example folder in the repository.

class PaginatedListScreen extends StatelessWidget {
  const PaginatedListScreen({super.key});

  // Simulating an API call
  Future<List<String>> fetchItems(int page) async {
    await Future.delayed(const Duration(seconds: 2)); // Simulate network delay
    return List.generate(10, (index) => 'Item ${(page - 1) * 10 + index + 1}');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Paginated ListView')),
      body: PaginatedListView<String>(
        fetchData: fetchItems,
        itemBuilder: (context, item) => ListTile(title: Text(item)),
        itemsPerPage: 10,
        initialPage: 1,
        totalPagesFromApi: 5, // Simulated total pages
        loadingWidget: const Center(child: CircularProgressIndicator()),
        emptyWidget: const Center(child: Text('No items found')),
        errorWidget: const Center(child: Text('Error loading data')),
        separatorBuilder: (context, index) => const Divider(),
      ),
    );
  }
}

Additional information #

Contributing 🤝 I welcome contributions! If you’d like to improve this package, feel free to:

    Fork the repository
    Submit a pull request with your changes
    Report issues or suggest new features

Check out the CONTRIBUTING.md file (if applicable) for detailed guidelines.

Reporting Issues 🐛 If you encounter a bug or have a feature request, please open an issue on the GitHub Issues page. When reporting an issue, please provide:

    A clear description of the problem
    Steps to reproduce (if applicable)
    Expected vs. actual behavior
    Logs or screenshots (if relevant)
5
likes
0
points
18
downloads

Publisher

unverified uploader

Weekly Downloads

`AutoPaginatedList` is a Flutter widget that simplifies infinite scrolling and pagination using `Provider` for state management. It automatically fetches more data as the user scrolls, supports custom loading, error, and empty states, and allows flexible configurations like separators, initial page, and scroll physics. Optimized for smooth performance, it ensures seamless data handling in list-based UIs.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, provider

More

Packages that depend on auto_paginated_list