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

套件詳情v1.0.2

search_widget

一個 Flutter 套件,提供了一個搜尋小工具,用於從資料列表中選擇一個選項。

近 30 天下載
61
喜歡數
144
Pub 分數
40

安裝套件

flutter pub add search_widget

套件介紹

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

一個 Flutter 套件,提供可自定義的搜尋小工具,用於從資料清單中選擇選項。它透過提供直覺的介面來動態過濾和選擇項目,簡化了搜尋功能的實作。適用於需要快速存取大量資料集的應用程式,支援即時過濾,並能順暢整合至現有 UI 中。此套件輕量且以開發者體驗為設計核心。

適用情境

  • 在表單中篩選大型數據集
  • 搜尋使用者清單
  • 實現快速選擇下拉框
  • 透過可搜尋選單增強導航
  • 建構動態自動完成功能

主要特色

  • 即時搜尋篩選
  • 可自訂的 UI 組件
  • 與現有小部件的輕鬆整合
  • 支援非同步資料來源
  • 輕量且高效

適合對象

  • 開發資料密集型應用的開發者
  • 需要可搜尋下拉選單的應用
  • 具有動態內容選擇的 UI
  • 注重快速功能開發的團隊
  • 專案需要最少的樣板程式碼

使用建議

  • 有限的平台特定自訂
  • 大型數據集沒有內建分頁
  • 需要手動處理加載狀態
  • 未針對極大資料集進行優化,除非使用批次處理
  • 依賴外部資料來源管理

原始 README

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

Search Widget Cirrus CI - Base Branch Build Status GitHub stars Twitter Follow GitHub last commit Website shields.io Open Source Love style: effective dart

This Flutter package provides a Search Widget for selecting an option from a data list. Provides filtering of items based on the search text.

PieChart

💻 Installation

In the dependencies: section of your pubspec.yaml, add the following line:

Version

dependencies:
  search_widget: <latest version>

❔ Usage

Import this class
import 'package:search_widget/search_widget.dart';
Add Search Widget
  • Accepts data list as input
  • Option for getting selected item. Returns selected item or null if item is deleted
onItemSelected: (item) {
    //Do whatever you would like
    setState(() {
       _selectedItem = item;
    });
 },
  • Option for pop list item builder. This basically returns a widget to show as list item in popup
popupListItemBuilder: (LeaderBoard item) {
   return PopupListItem(item);
 }
  • Option for filtering data list based on search query
queryBuilder: (String query, List<LeaderBoard> list) {
   return list.where((LeaderBoard item) => item.username.toLowerCase().contains(query.toLowerCase())).toList();
 }
  • Option provided for selected list item builder which enables when a user selects an item from pop up list
selectedItemBuilder: (LeaderBoard selectedItem, deleteSelectedItem) {
   return SelectedItem(selectedItem,deleteSelectedItem);
 }
  • Option for providing custom TextField. Accepts TextEditingController and FocusNode as parameter
textFieldBuilder: (TextEditingController controller, FocusNode focusNode) {
    return TextField(
        controller: controller,
        focusNode: focusNode,
        //... Other customizations here
       );
  },
Full Implementation
SearchWidget<LeaderBoard>(
   dataList: list,
   hideSearchBoxWhenItemSelected: false,
   listContainerHeight: MediaQuery.of(context).size.height / 4,
   queryBuilder: (String query, List<LeaderBoard> list) {
     return list.where((LeaderBoard item) => item.username.toLowerCase().contains(query.toLowerCase())).toList();
   },
   popupListItemBuilder: (LeaderBoard item) {
     return PopupListItemWidget(item);
   },
   selectedItemBuilder: (LeaderBoard selectedItem, VoidCallback deleteSelectedItem) {
     return SelectedItemWidget(selectedItem, deleteSelectedItem);
   },
   // widget customization
   noItemsFoundWidget: NoItemsFound(),
   textFieldBuilder: (TextEditingController controller, FocusNode focusNode) {
     return MyTextField(controller, focusNode);
   },
 )
Key Highlights
  • Adaptive Popup Position to prevent popup getting hidden behind keyboard

PieChart PieChart

  • Popup to scroll with scroll gesture if this widget is used inside ScrollView
PieChart

TODO

  • [X] Give support for onItemSelected method to return selected item(s) directly
  • [ ] Add support for selecting multiple items
  • [ ] Add visibility bool to show selected item widget

⭐ My Flutter Packages

  • pie_chart GitHub stars Flutter Pie Chart with cool animation.
  • avatar_glow GitHub stars Flutter Avatar Glow Widget with glowing animation.
  • json_table GitHub stars Create Flutter Json Table from json map directly.
  • animating_location_pin GitHub stars Flutter Animating Location Pin Widget providing Animating Location Pin Widget which can be used while fetching device location.

⭐ My Flutter Apps

👍 Contribution

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。