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

GitHub 代码仓Okladnoj/search_autocomplete

搜索自动完成

Okladnoj/search_autocomplete open-source repository details.

搜索自动完成 项目封面
星标
2
复刻
2
最近推送(UTC)
2026年3月24日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

Search Autocomplete Flutter Package

Video

Buy Me A Pizza

Overview

This Flutter package provides a SearchAutocomplete widget for implementing autocomplete functionality with a dropdown menu. The package offers extensive customization options for the search field, dropdown items, and includes hooks for search logic.

Installation

To use this package, add search_autocomplete as a dependency in your pubspec.yaml file:

dependencies:
  search_autocomplete: ^1.0.3

Features

  • Customizable search field
  • Customizable dropdown items
  • Hooks for search logic
  • Initial value support
  • Placeholder text support
  • Widget to display when the dropdown is empty
State Management Compatibility
  • Designed to work seamlessly with Cubit/Bloc and other orthodox state managers. Since the list updating logic resides higher up in the widget tree, it allows for a clean separation between UI and logic.

Usage

Here's a simple example demonstrating how to use the SearchAutocomplete widget:

Basic example:
SearchAutocomplete<String>(
  options: state.filteredItems, // Like: ['Apple', 'Banana', 'Orange'],
  initValue: state.currentItem, // Like: 'Apple',
  getString: (item) => item,
  onSearch: (query) {
    // Call your Bloc/Cubit/Provider method to filter options based on the query
    context.read<SearchCubit>().search(query);
  },
  onSelected: (item) {
    // Update your Bloc/Cubit/Provider state when an item is selected
    context.read<SearchCubit>().select(item);
  },
  hintText: 'Search fruits...',
)
Customization example:

You can customize both the search field and dropdown items appearance using provided builders:

SearchAutocomplete<String>(
  options: state.filteredItems,
  initValue: state.currentItem,
  getString: (item) => item,

  onSearch: (query) {
    context.read<SearchCubit>().search(query);
  },

  onSelected: (item) {
    context.read<SearchCubit>().select(item);
  },

  fieldBuilder: (controller, onFieldTap, showDropdown, onPressed) {
    return TextFormField(
      controller: controller,
      onTap: onFieldTap,
      decoration: InputDecoration(
        hintText: 'Custom search...',
        suffixIcon: IconButton(
          icon: Icon(
            showDropdown ? Icons.arrow_drop_up : Icons.arrow_drop_down,
          ),
          onPressed: () => onPressed(showDropdown),
        ),
      ),
    );
  },

  dropDownBuilder: (options, onSelected, controller) {
    return ListView.builder(
      itemCount: options.length,
      itemBuilder: (context, index) {
        final option = options[index];
        return ListTile(
          leading: Icon(Icons.star),
          title: Text(option),
          onTap: () => onSelected(option),
        );
      },
    );
  },

  emptyDropDown: (controller, close) {
    return Center(child: Text('No results found.'));
  },
)

License

This package is licensed under the MIT License. See the LICENSE.md file for details.

Dmitriy GitHub avatar
GitHub 作者

Dmitriy ↗

Харьков
语言DartC++CMakeShellSwiftHTMLCKotlinObjective-C

此仓库发布的插件

使用的依赖

依赖清单 3 项

  • flutter{"sdk":"flutter"}
  • flutter_test开发依赖{"sdk":"flutter"}
  • flutter_lints开发依赖^4.0.0

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗