/Easy_Pagination_Cubit

Easy Pagination is a simple and efficient pagination Repo for Flutter applications. This repo allows you to easily implement pagination in your Flutter apps with minimal setup and code. It's designed to be highly customizable and compatible with various data sources.

Primary LanguageDart

📖 Easy Pagination Cubit 📖

🚀 Getting Started

  • A Flutter application showcasing pagination implementation using the flutter_bloc library. This project demonstrates how to efficiently load and display data in chunks, providing a smooth user experience with minimal resource consumption.

🪄 Features

  • Pagination with Cubit: Utilize the power of flutter_bloc for efficient state management in paginated scenarios.

  • Efficient Data Loading: Load data in chunks to minimize the impact on performance.

  • Loading States: Handle loading states to keep users informed during data fetching.

  • Error Handling: Gracefully handle errors during data retrieval.


⚙️ Customization

  • Customize the appearance and behavior of the clipboard according to your requirements:

PaginationCubit:

class PaginationCubit extends Cubit<List<dynamic>> {
  PaginationCubit() : super([]);

  int _page = 1;
  bool _isFetching = false;

  Future<void> fetchItems() async {
    if (_isFetching) return;
    _isFetching = true;

    try {
      final response = await Dio().get(
          'https://jsonplaceholder.typicode.com/posts',
          queryParameters: {'_page': _page, '_limit': 10});
      final List<dynamic> items = response.data;
      emit(List.from(state)..addAll(items));
      _page++;
      debugPrint('Page: $_page');
    } catch (e) {
      debugPrint('Error: $e');
    } finally {
      debugPrint('Total Fetched Items Num: ${state.length}');
      _isFetching = false;
    }
  }
}

📱 UI

Easy.Pagination.Cubit.mp4

🛠 Dependencies

  flutter_bloc: ^8.0.0
  dio: ^4.0.0

🫴 Contributing

  • Contributions are welcome 💜
  • If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

💳 License

License: MIT Version

  • This package is distributed under the MIT License. Feel free to use and modify it according to your project requirements.

🤝 Contact With Me

LinkedIn Gmail Facebook Instagram


💖 Support

  • If you find this tutorial useful or learned something from this code, consider show some ❤️ by starring this repo.