pagination_dropdown_list 0.2.0
pagination_dropdown_list: ^0.2.0 copied to clipboard
flutter drop down list with paganation that enable you to fectch data while scrolling.
pagination_dropdown_list #
A powerful and easy-to-use Flutter widget that displays a dropdown list with built-in pagination support.
Perfect for loading large datasets efficiently without fetching all data at once.
π Features #
β
Load data in pages as the user scrolls
β
Display loading spinner while fetching next page
β
Handle empty, error, and βno more dataβ states
β
Support for custom item parsing and pre-selected items
β
Fully customizable design
β
Easy integration with any API or data source
π¦ Installation #
Add the dependency in your pubspec.yaml
:
dependencies:
pagination_dropdown_list: ^1.0.0
Then, import it in your Dart file:
import 'package:pagination_dropdown_list/pagination_dropdown_list.dart';
π§© Example #
PaginationDropdownList(
textTitle: 'User',
hintText: 'Select user',
initialItem: currentUser.name,
onChanged: (user) => print('Selected: $user'),
itemParser: (user) => user.name,
fetchItems: (page, pageSize) async => await ApiService().getUsers(page, pageSize),
)
βοΈ Parameters #
Parameter | Type | Description |
---|---|---|
textTitle | String |
Title shown above the dropdown. |
hintText | String |
Hint text displayed when no item is selected. |
initialItem | dynamic |
Pre-selected value shown when the widget loads. |
onChanged | Function(T item) |
Callback triggered when a user selects an item. |
itemParser | Function(T item) |
Function that defines how to display each item as a string. |
fetchItems | Future<List<T>> Function(int page, int pageSize) |
Asynchronous function used to fetch data by page. |
pageSize | int |
Number of items per page (default: 10). |
noMoreItemsMessage | String? |
Message displayed when no more data is available. |
errorMessage | String? |
Message displayed when an error occurs. |
notItemMessage | String? |
Message displayed when no items are found. |
π§ How It Works #
- When the dropdown opens, it calls
fetchItems(page = 1)
to load the first page. - As the user scrolls, it automatically triggers
fetchItems(page++)
when reaching the end. - The widget handles loading and "no more items" states automatically.
- You can replace the simulated API with your own backend service.
π¨ Customization #
You can style the dropdown, adjust its size, and use custom item builders for advanced UI.
Itβs fully compatible with Material 3 and Directionality (RTL/LTR).
πΈ Preview #
![Example preview]!(preview_img.png)
π§Ύ Notes #
- Works perfectly with REST APIs, Firebase, or any async data source.
- Pagination logic runs independently of your UI, so your app stays responsive.
- Ideal for large datasets like products, users, or countries.
β€οΈ Contributing #
Contributions, issues, and feature requests are welcome!
Feel free to open a PR or issue on GitHub.
Developed by: Engineer Mahfoud Mohammed Bin Sabbah
License: MIT
Pub.dev: pagination_dropdown_list