搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。