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

multiple_search_selection 封面
套件詳情v3.0.0

multiple_search_selection

一個高度可自訂的多選組件,具備模糊搜尋功能。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1370
喜歡數
73
Pub 分數
150

安裝套件

flutter pub add multiple_search_selection

套件介紹

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

一個高度可自訂的多重選擇元件,內建模糊搜尋功能,讓使用者能從大量資料中有效率地選取多個項目。支援即時過濾與智慧匹配,非常適合用於表單、標籤或篩選功能,讓使用者可以挑選多個選項。此元件設計為跨平台流暢運作,並提供廣泛的樣式與行為自訂功能。基於 Flutter 建構,可無縫整合至針對 Android、iOS、Web、macOS、Windows 與 Linux 所開發的應用程式中。

適用情境

  • 具有多個選項的表單輸入
  • 標籤選擇介面
  • 具有動態搜尋的過濾系統
  • 用戶偏好選擇
  • 帶搜尋功能的動態下拉選單
  • 管理介面中的多選

主要特色

  • 模糊搜尋以實現靈活匹配
  • 可自定義的使用者介面和樣式
  • 對大型數據集的支援
  • 跨平台相容性
  • 即時搜尋篩選
  • 多選並提供清晰反饋

適合對象

  • 開發複雜表單組件的開發者
  • 需要高效多項目選擇的應用程式
  • 需要在下拉選單中進行智慧搜尋的專案
  • 優先考慮跨平台一致性的團隊
  • 想要一個輕量級但功能強大的選擇小部件的使用者

使用建議

  • 可能需要針對非常大的資料集進行調整
  • 自訂選項可能會增加初始設定的複雜性
  • 性能取決於項目渲染優化
  • 有限的內建驗證功能
  • 不適用於單選使用情境

原始 README

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

Version Version

Show some love by dropping a ⭐ at GitHub
HTML tutorial

A highly customizable multiple selection widget with fuzzy search functionality
// Use this controller to adjust the behaviour of the widget
// 1. getAllItems
// 2. getPickedItems
// 3. searchItems
// 4. clearSearchField
// 5. clearAllPickedItems
// 6. selectAllItems
// 7. minCharsToShowItems
// 8. allowDuplicateSelection
// 9. isSelectable
MultipleSearchController controller = MultipleSearchController();
MultipleSearchSelection<Country>(
  // The TextField that is used to search items.
  //
  // You can use this to customize the search field.
  // The `onChanged` of the `searchField` is used internally to search items,
  // so you can use the `onSearchChanged` callback to get the search query.
  searchField: TextField(
    decoration: InputDecoration(
      hintText: 'Search countries',
      border: OutlineInputBorder(
        borderRadius: BorderRadius.circular(6),
        ),
      ),
    ),
  onSearchChanged: (text) {
    print('Text is $text');
  },
  items: countries, // List<Country>
  fieldToCheck: (c) {
    return c.name; // String
  },
  itemBuilder: (country,index,isPicked) {
    return Padding(
      padding: const EdgeInsets.all(6.0),
      child: Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(6),
          color: Colors.white,
        ),
        child: Padding(
          padding: const EdgeInsets.symmetric(
            vertical: 20.0,
            horizontal: 12,
          ),
          child: Text(country.name),
        ),
      ),
    );
  },
  pickedItemBuilder: (country) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        border: Border.all(color: Colors.grey[400]!),
      ),
      child: Padding(
        padding: const EdgeInsets.all(8),
        child: Text(country.name),
      ),
    );
  },
  onTapShowedItem: () {},
  onPickedChange: (items) {},
  onItemAdded: (item) {},
  onItemRemoved: (item) {},
  sortShowedItems: true,
  sortPickedItems: true,
  fuzzySearch: FuzzySearch.jaro,
  itemsVisibility: ShowedItemsVisibility.alwaysOn,
  title: Text(
    'Countries',
    style: kStyleDefault.copyWith(
      fontSize: 22,
      fontWeight: FontWeight.bold,
    ),
  ),
  showSelectAllButton: true,
  maximumShowItemsHeight: 200,
)
MultipleSearchSelection<T>.creatable

MultipleSearchSelection<T>.creatable constructor can now create new item when search result does not return any results. It takes a new required parameter, createOptions e.g :

// [T] here is [Country]
createOptions: CreateOptions<Country>(
    // You need to create and return the item you want to add since [T] is not always [String].
    create: (text) {
        return Country(name: text, iso: text);
    },
    // A callback when the item is succesfully created.
    onCreated: (c) => print('Country ${c.name} created'),
    // Create item Widget that appears instead of no results.
    createBuilder: (text) => Align(
        alignment: Alignment.centerLeft,
            child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text('Create "$text"'),
            ),
        ),
    // Whether you want to pick the newly created item or just add it to your list. Defaults to false.
    pickCreated: true,
),
Creatable
Showed items visibility

itemsVisibility behaviour for the default & creatable constructors

ShowedItemsVisibility.alwaysOn ShowedItemsVisibility.onType ShowedItemsVisibility.toggle
Always On On type Toggle

Issues / Features

Found a bug or want a new feature? Open an issue in the Github repository of the project.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。