搜尋套件、儲存庫與 APP 分類

searchable_paginated_dropdown 封面
套件詳情v1.3.0

searchable_paginated_dropdown

可用於分頁請求的 Flutter 可搜尋下拉選單組件。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2190
喜歡數
43
Pub 分數
150

安裝套件

flutter pub add searchable_paginated_dropdown

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 小部件,結合可搜尋下拉選單與分頁資料載入支援。它讓使用者能夠動態過濾選項,同時透過懶加載有效處理大型資料集。非常適合需要大量選擇清單的表單或介面,而不會造成效能下降。該小部件可與非同步資料來源無縫整合,適用於 API 驅動的應用程式。支援所有主要平台,包括行動裝置、網頁和桌面。

適用情境

  • 大型數據集選擇
  • 基於 API 的下拉選單
  • 帶過濾功能的表單輸入
  • 動態數據加載
  • 行動應用程式中的可搜尋清單
  • 網頁和桌面下拉選單

主要特色

  • 可搜尋的輸入欄位
  • 分頁資料取得
  • 非同步資料支援
  • 跨平台相容性
  • 可自訂樣式
  • 高效記憶體使用

適合對象

  • 開發包含大量選項的表單的開發者
  • 使用遠端 API 取得下拉資料的應用程式
  • 需要響應式搜尋功能的專案
  • 跨平台 Flutter 應用程式
  • 需要流暢滾動和篩選的 UI

使用建議

  • 需要非同步資料來源設定
  • 網路請求需要適當的錯誤處理
  • 複雜設計可能需要自訂UI調整
  • 效能取決於分頁策略
  • 有限的內建驗證
  • 依賴外部套件依賴

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

This Flutter package helps create a dropdown which constains a search bar inside. And also provides a feature for compatibility with paginated searchable requests.

Features

  • SearchableDropdown for pre setted item list,
  • SearchableDropdown.paginated for paginated requests.
  • SearchableDropdown.future for normal requests.
  • SearchableDropdownFormfield for compatibility with forms.

Getting started

To use this package, add searchable_dropdown as a dependency in your [pubspec.yaml] file. And add this import to your file.

import 'package:searchable_dropdown/searchable_dropdown.dart';

Usage

Pre setted item list example

SearchableDropdown<int>(
    hintText: const Text('List of items'),
    margin: const EdgeInsets.all(15),
    items: List.generate(10, (i) => SearchableDropdownMenuItem(value: i, label: 'item $i', child: Text('item $i'))),
    onChanged: (int? value) {
        debugPrint('$value');
    },
)

Paginated request example

  • requestItemCount: Paginated request item count which returns in one page, this value is using for knowledge about isDropdown has more item or not.
SearchableDropdown<int>.paginated(
    hintText: const Text('Paginated request'),
    margin: const EdgeInsets.all(15),
    paginatedRequest: (int page, String? searchKey) async {
        final paginatedList = await getAnimeList(page: page, key: searchKey);
        return paginatedList?.animeList
            ?.map((e) => SearchableDropdownMenuItem(value: e.malId, label: e.title ?? '', child: Text(e.title ?? '')))
            .toList();
    },
    requestItemCount: 25,
    onChanged: (int? value) {
        debugPrint('$value');
    },
)

Future request example

SearchableDropdown<int>.future(
    hintText: const Text('Future request'),
    margin: const EdgeInsets.all(15),
    futureRequest: () async {
        final paginatedList = await getAnimeList(page: 1, key: '');
        return paginatedList?.animeList
            ?.map((e) => SearchableDropdownMenuItem(value: e.malId, label: e.title ?? '', child: Text(e.title ?? '')))
            .toList();
    },
    onChanged: (int? value) {
        debugPrint('$value');
    },
)

Example of usage inside a form.

  • backgroundDecoration: Background decoration of dropdown, i.e. with this you can wrap dropdown with Card
Form(
    key: formKey,
    child: SearchableDropdownFormField<int>(
        backgroundDecoration: (child) => Card(
            margin: EdgeInsets.zero,
            color: Colors.red,
            elevation: 3,
            child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: child,
            ),
        ),
        hintText: const Text('Search Anime'),
        margin: const EdgeInsets.all(15),
        items: List.generate(10, (i) => SearchableDropdownMenuItem(value: i, label: 'item $i', child: Text('item $i'))),
        validator: (val) {
            if (val == null) return 'Cant be empty';
            return null;
        },
        onSaved: (val) {
            debugPrint('On save: $val');
        },
    ),
)

License

License

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。