搜索插件、代码仓与 APP 分类

插件详情v3.0.0

flutter_search_bar

一个(大部分)自动的搜索栏,内置于 Flutter 的 AppBar 中

近 30 天下载
1110
喜欢数
121
Pub 分数
60

安装插件

flutter pub add flutter_search_bar

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,提供集成在 AppBar 中的搜索栏,设置简单。它会自动处理搜索输入、过滤和 UI 更新,非常适合在应用程序中添加搜索功能而无需编写大量样板代码。该搜索栏支持实时过滤,并可根据各种设计需求进行自定义。它专为无缝融入 AppBar 而设计,提供简洁直观的用户体验。该包在 GitHub 上维护,适合希望在 Flutter 应用程序中快速实现搜索功能的开发者。

适合场景

  • 在列表视图中实现搜索
  • 实时过滤数据
  • 通过搜索增强应用导航
  • 将搜索功能集成到应用栏中
  • 构建动态内容过滤器

主要特点

  • 自动管理的搜索状态
  • 实时过滤
  • AppBar 集成
  • 最小配置
  • 可自定义的用户界面
  • 支持异步过滤

适合对象

  • 开发搜索密集型应用的开发者
  • 需要快速搜索实现的应用程序
  • 需要干净搜索栏的以用户界面为重点的项目
  • Flutter 初学者探索搜索功能
  • 具有动态数据源的项目

使用建议

  • 有限的平台特定自定义
  • 无内置建议或自动完成
  • 需要手动处理异步结果
  • 未针对非常大的数据集进行优化
  • 依赖外部状态管理来处理复杂逻辑

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Archive Notice

This repository is archived. 3.0.0 is the last version that I will publish.

The SearchBar still works and it's pretty simple if you'd like to fork it. I just don't have the time to maintain it.

flutter_search_bar

A simple and mostly automatic material search bar for flutter (dart).

Note: use flutter_search_bar and not search_bar -- I own both packages but I'm just a tad bit locked out of search_bar, so it won't be updated.

Screenshots

Normal state (search is not active yet, only title and actions are set, with the only action being a search button)

Normal State

inBar set to false (background white, back button inherited):

inBar false

inBar set to true (background inherited):

inBar true

Usage

A simple usage example:

class _MyHomePageState extends State<MyHomePage> {
  SearchBar searchBar;
  
  AppBar buildAppBar(BuildContext context) {
    return new AppBar(
      title: new Text('My Home Page'),
      actions: [searchBar.getSearchAction(context)]
    );
  }  
  
  _MyHomePageState() {
    searchBar = new SearchBar(
      inBar: false,
      setState: setState,
      onSubmitted: print,
      buildDefaultAppBar: buildAppBar
    );
  }
  
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: searchBar.build(context)
    );
  }
}

This will create an AppBar with a search button as its only action, and on press the AppBar will turn white and have a TextField inside, allowing user input. Once the user has input something and pressed the "enter" button on their keyboard, it will close and the value will be printed to the debugger.

Using SearchBar

Essentially, this class returns two different app bars based on whether search is active.

The setState callback you pass the search bar can technically be any VoidCallback.

Features and bugs

Please file feature requests and bugs at the issue tracker.

We've recently added support for null-safety in 3.0.0 -- if you find any issues, please report them there!

所属分类

源码仓库

使用此插件的项目