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

field_suggestion 封面
插件详情v0.2.6

field_suggestion

创建高度可定制、简单且可控的自动补全字段。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
643
喜欢数
45
Pub 分数
160

安装插件

flutter pub add field_suggestion

插件介绍

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

FieldSuggestion 是一个 Flutter 包,可帮助开发者创建高度可自定义、简单且可控的自动补全字段。它提供了一个简洁的 API,用于构建带有实时建议的输入字段,支持文本和自定义小部件渲染。该包可在 Android、iOS、Web、macOS、Windows 和 Linux 等所有主要平台上运行,非常适合需要智能输入处理的跨平台应用。通过内置的建议显示控制、过滤逻辑和样式设置,FieldSuggestion 在保持灵活性的同时避免了复杂性。

适合场景

  • 带有动态建议的表单输入
  • 带预测文本的搜索栏
  • 表单中的自定义下拉菜单
  • 用户友好的数据输入界面
  • 实时过滤大型数据集

主要特点

  • 高度可定制的建议UI
  • 跨平台兼容性
  • 简单直观的 API
  • 支持在建议中使用自定义组件
  • 内置的过滤和控制逻辑
  • 轻量且高效

适合对象

  • 开发表单密集型应用的开发者
  • 需要一致自动补全行为的团队
  • 需要跨平台输入组件的应用程序
  • 需要复杂用户输入的项目

使用建议

  • 需要手动实现数据源逻辑
  • 有限的内置主题或样式预设
  • 最适合静态或可预测的建议源

原始 README

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


Field Suggesion's Logo

Field Suggesion's Title Logo


Installing

Usage

In this example, we're using the FieldSuggestion.network widget to display suggestions for a username input field. We've provided an inputDecoration with a hint text, a future function that fetches the suggestions based on the user input, a textController that controls the text in the input field, a boxController that controls the visibility of the suggestion box, and a builder function that defines how the suggestions are displayed in the suggestion box.

Note that FieldSuggestion uses generics to allow for suggestions of different types. In the example above, we're using String as the type parameter for FieldSuggestion.network However, any other type can be used, depending on the type of suggestions being displayed.

FieldSuggestion<String>.network(
  inputDecoration: InputDecoration(
    hintText: 'Username', // optional
  ),
  future: (input) => future.call(input),
  textController: controller,
  boxController: boxController, // optional
  builder: (context, snapshot) {
    if (snapshot.connectionState != ConnectionState.done) {
      return Center(child: CircularProgressIndicator());
    }

    final result = snapshot.data ?? [];
    return ListView.builder(
      itemCount: result.length,
      itemBuilder: (context, index) {
        return GestureDetector(
          onTap: () {
            setState(() => controller.text = result[index]);
            boxControllerNetwork.close?.call();
          },
          child: Card(child: ListTile(title: Text(result[index]))),
        );
      },
    );
  },
)

Contributing

  • For information regarding contributions, please refer to CONTRIBUTING.md file.

所属分类

依赖

依赖清单 1 项

  • highlightable^1.0.5

源码仓库

使用此插件的项目

暂无相关数据。