Skip to main content

high_q_paginated_drop_down 2.1.9 copy "high_q_paginated_drop_down: ^2.1.9" to clipboard
high_q_paginated_drop_down: ^2.1.9 copied to clipboard

Package handles the pagination and search in DropDown .

High Q Paginated DropDown #

pub package pub points license

A powerful, performant, and highly customizable Flutter dropdown package. It supports single and multi-selection, asynchronous pagination with infinite scrolling, in-memory caching, live search with debouncing, item grouping with headers, selection limits, keyboard navigation, and native Flutter Form validation.


📸 Preview #

Single & Multi-Select Paginated Search Custom Styling & Dialogs
Screenshot

✨ Features #

  • 📄 Asynchronous Pagination: Efficiently load massive datasets page-by-page as the user scrolls.
  • 💾 Smart In-Memory Caching: Cache fetched pages with enableCache: true to prevent redundant network requests.
  • 🔍 Search & Debouncing: Live search filtering with configurable debouncing durations.
  • 🏷️ Grouped Items: Organize items into sections with custom header widgets using GroupProps.
  • ☑️ Single & Multi-Select: Support for both single-item picking and multi-item checkbox selection.
  • 🚫 Selection Limits: Restrict the maximum number of selectable items (SelectionLimitProps).
  • 📋 Select All / Deselect All: Built-in one-click bulk selection for multi-select dropdowns.
  • ⌨️ Keyboard Navigation: Navigate dropdown items using Arrow Up/Down and select with Enter (Desktop & Web ready).
  • 📝 Native Form Integration: Works seamlessly with Flutter's Form widget and validation.
  • 🎨 Deep Customization: Multiple display modes (Dropdown Menu, Dialog, Modal Bottom Sheet) and custom item, header, loading, error, and empty builders.
  • ⚡ Unified API: Clean, intuitive widget constructors under HighQDropDown.

📦 Installation #

Add high_q_paginated_drop_down to your pubspec.yaml:

flutter pub add high_q_paginated_drop_down

Or manually:

dependencies:
  high_q_paginated_drop_down: ^2.1.9

Import it in your Dart code:

import 'package:high_q_paginated_drop_down/high_q_paginated_drop_down.dart';

🚀 Unified Constructors Overview #

Use HighQDropDown with the constructor that best fits your use case:

Constructor Description
HighQDropDown(...) Single-selection with a static in-memory list
HighQDropDown.paginated(...) Single-selection with asynchronous page-by-page fetching
HighQDropDown.multiSelect(...) Multi-selection with a local list or asynchronous search
HighQDropDown.paginatedMultiSelect(...) Multi-selection with asynchronous pagination

Note: For backward compatibility, the underlying widgets (HighQSingleDropDown, HighQPaginatedDropdown, HighQMultiSelectDropDown, HighQMultiSelectPaginatedDropDown) remain available and accessible.


💻 Usage Examples #

1. Basic Single Select (Static List) #

HighQDropDown<String>(
  items: ['Flutter', 'Dart', 'React Native', 'Kotlin']
      .map(
        (lang) => MenuItemModel<String>(
          value: lang,
          label: lang,
          child: Text(lang),
        ),
      )
      .toList(),
  initialValue: 'Flutter',
  searchProps: const SearchProps(
    showTextField: true,
    searchDelayDuration: Duration(milliseconds: 300),
  ),
  onChanged: (value) {
    debugPrint('Selected: $value');
  },
)

HighQDropDown<UserModel>.paginated(
  requestProps: PaginatedRequestProps<UserModel>(
    requestItemCount: 15,
    enableCache: true, // Caches loaded pages to eliminate redundant API calls
    paginatedRequest: (int page, String? searchText) async {
      final List<UserModel> users = await ApiService.fetchUsers(
        page: page,
        query: searchText,
      );
      return users
          .map(
            (user) => MenuItemModel<UserModel>(
              value: user,
              label: user.name,
              child: Text(user.name),
            ),
          )
          .toList();
    },
  ),
  validatorProps: SingleValidatorProps(
    validator: (user) => user == null ? 'Please select a user' : null,
  ),
  onChanged: (UserModel? user) {
    debugPrint('Selected User: ${user?.name}');
  },
)

3. Multi-Select (with Selection Limits & Select All) #

HighQDropDown<String>.multiSelect(
  itemsLogicProps: ItemsLogicProps<String>(
    items: ['Apple', 'Banana', 'Orange', 'Mango', 'Strawberry'],
  ),
  // Limit max selections:
  selectionLimitProps: SelectionLimitProps(
    maxSelectableItems: 3,
    onMaxSelectionReached: (context, limit) {
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(content: Text('You can select a maximum of $limit items!')),
      );
    },
  ),
  // Enable search and Select All button:
  popupProps: const PopupPropsMultiSelection.menu(
    showSearchBox: true,
    showSelectAll: true,
  ),
  methodLogicProps: MethodLogicProps<String>(
    onChanged: (List<String> selectedList) {
      debugPrint('Selected items: $selectedList');
    },
  ),
)

4. Paginated Multi-Select (with Custom Objects & compareFn) #

When dealing with custom objects fetched from an API, always provide compareFn:

HighQDropDown<UserModel>.paginatedMultiSelect(
  paginatedRequest: (int page, String? filter) async {
    return await ApiService.fetchUsers(page: page, query: filter);
  },
  requestItemCount: 20,
  itemsLogicProps: ItemsLogicProps<UserModel>(
    itemAsString: (UserModel? user) => user?.name ?? '',
  ),
  // Essential for custom objects across paginated pages:
  filterAndCompareProps: FilterAndCompareProps<UserModel>(
    compareFn: (item1, item2) => item1.id == item2.id,
  ),
  popupProps: const PopupPropsMultiSelection.menu(
    showSearchBox: true,
    showSelectAll: true,
  ),
  methodLogicProps: MethodLogicProps<UserModel>(
    onChanged: (List<UserModel> users) {
      debugPrint('Selected ${users.length} users');
    },
  ),
)

5. Grouped Items Dropdown #

Organize items into grouped sections with custom header widgets:

HighQDropDown<ProductModel>.multiSelect(
  itemsLogicProps: ItemsLogicProps<ProductModel>(
    items: productList,
    itemAsString: (product) => product?.title ?? '',
  ),
  filterAndCompareProps: FilterAndCompareProps<ProductModel>(
    compareFn: (p1, p2) => p1.id == p2.id,
  ),
  groupProps: GroupProps<ProductModel>(
    showGroups: true,
    groupBy: (product) => product.category, // Extract category string
    groupHeaderBuilder: (context, groupName) {
      return Container(
        padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
        color: Colors.indigo.shade50,
        child: Text(
          groupName,
          style: const TextStyle(
            fontWeight: FontWeight.bold,
            color: Colors.indigo,
          ),
        ),
      );
    },
  ),
  methodLogicProps: MethodLogicProps<ProductModel>(
    onChanged: (selectedProducts) {
      debugPrint('Selected count: ${selectedProducts.length}');
    },
  ),
)

6. Form Integration & Validation #

The dropdown integrates directly with Flutter's standard Form widget:

final formKey = GlobalKey<FormState>();

Form(
  key: formKey,
  child: Column(
    children: [
      HighQDropDown<String>(
        items: items,
        validatorProps: SingleValidatorProps(
          validator: (value) {
            if (value == null || value.isEmpty) {
              return 'Selection is required';
            }
            return null;
          },
        ),
        onSaved: (val) {
          // Save value
        },
      ),
      ElevatedButton(
        onPressed: () {
          if (formKey.currentState?.validate() ?? false) {
            formKey.currentState?.save();
            debugPrint('Form is valid!');
          }
        },
        child: const Text('Submit'),
      ),
    ],
  ),
)

⚠️ Important: Handling Custom Objects (compareFn) #

When working with custom model classes (e.g., UserModel, Product), Dart compares objects by reference (memory address) by default.

When new pages are fetched or the dropdown is closed and reopened, newly instantiated models have different memory addresses, even if they have the exact same id.

To ensure the dropdown correctly identifies selected items across pagination pages, provide a compareFn:

filterAndCompareProps: FilterAndCompareProps<MyModel>(
  compareFn: (item1, item2) => item1.id == item2.id,
)

Alternatively, override == and hashCode in your model class (or use packages like equatable or freezed).


🎛️ Display Modes #

In multi-select mode, you can display the selection popup as a Dropdown Menu, Dialog, or Modal Bottom Sheet:

// 1. Popup Menu (Default)
popupProps: const PopupPropsMultiSelection.menu(
  showSearchBox: true,
)

// 2. Dialog Mode
popupProps: const PopupPropsMultiSelection.dialog(
  showSearchBox: true,
  dialogProps: DialogProps(
    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
  ),
)

// 3. Modal Bottom Sheet
popupProps: const PopupPropsMultiSelection.modalBottomSheet(
  showSearchBox: true,
  modalBottomSheetProps: ModalBottomSheetProps(
    isScrollControlled: true,
    backgroundColor: Colors.white,
  ),
)

📋 Properties Reference #

Property Class Description
PaginatedRequestProps Handles async pagination callbacks, item count per page, and enableCache flag
GroupProps Configures item grouping (showGroups, groupBy, groupHeaderBuilder, groupHeaderStyle)
SelectionLimitProps Sets maxSelectableItems limit and triggers onMaxSelectionReached callback
SingleValidatorProps Provides validator and autoValidateMode for single-select form validation
ValidatorProps Provides validator for multi-select form validation
SearchProps Configures search visibility, decoration, and debounce delay duration
DropDownDecoratorProps Customizes dropdown container border, label text, and hint styling
SelectedItemDecorationPros Customizes multi-select selected chips decoration and layout
PopupPropsMultiSelection Configures popup behavior, display mode, search box, builders, and Select All

💡 Keyboard Navigation #

Desktop and Web navigation is supported out of the box:

  • Arrow Down (↓): Focus next item
  • Arrow Up (↑): Focus previous item
  • Enter (⏎): Select / Toggle focused item

📂 Example App #

A full example project demonstrating all dropdown variants, empty states, grouping, and styling can be found in the example/ folder.

To run the example app:

cd example
flutter run

📄 License #

This project is licensed under the MIT License - see the LICENSE file for details.

5
likes
140
points
927
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Package handles the pagination and search in DropDown .

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

async, flutter

More

Packages that depend on high_q_paginated_drop_down