搜尋套件、儲存庫與 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 上維護,適合尋求簡便方案以實作搜尋功能的開發者。

適用情境

  • 在列表視圖中實現搜尋
  • 即時過濾資料
  • 透過搜尋增強應用程式導航
  • 將搜尋功能整合到應用程式欄中
  • 建構動態內容過濾器

主要特色

  • 自動管理的搜尋狀態
  • 即時過濾
  • 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!

所屬分類

原始碼儲存庫

使用此套件的專案