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

input_history_text_field 封面
插件详情v0.4.0

input_history_text_field

一个 input_history_text_field 小部件会自动保存并根据您的输入进行建议。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1320
喜欢数
80
Pub 分数
150

安装插件

flutter pub add input_history_text_field

插件介绍

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

input_history_text_field 包提供了一个 Flutter 小部件,可自动保存用户输入历史并在用户输入时提供建议。它通过记住之前的条目来增强表单的可用性,减少重复输入。非常适合用于搜索框、登录表单或任何需要保留过往输入的场景。该小部件支持 Android、iOS、Web、macOS、Windows 和 Linux 等多个平台,确保在各种设备上行为一致。该组件设计简洁且性能出色,可无缝集成到现有的 Flutter 应用中。

适合场景

  • 带有自动建议的搜索栏
  • 带有历史记录保留的表单输入
  • 登录或注册字段
  • 用户偏好设置
  • 快速访问频繁输入的文本
  • 增强的数据输入用户体验

主要特点

  • 自动保存输入历史
  • 输入时实时建议
  • 跨平台兼容性
  • 与现有表单的简单集成
  • 轻量且高效
  • 支持所有主要的Flutter平台

适合对象

  • 开发搜索界面的开发者
  • 需要重复用户输入的应用程序
  • 旨在提升用户体验的表单
  • 针对多个平台的项目
  • 希望历史功能设置最少的团队

使用建议

  • 需要手动处理存储持久化
  • 可能需要针对大型数据集进行定制
  • 由于本地存储,不适合敏感数据
  • 有限的内置样式选项
  • 依赖外部状态管理以支持高级用例

原始 README

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

input_history_text_field

A input_history_text_field widget is automatically saved and suggest as you type.

Overview

List

example1 example2
image image

Badge

example1 example2
image image

Customize

 
image

Getting Started

Usage

The only key in the your widget of application set to historyKey, supports like a text_field.

InputHistoryTextField(
    historyKey: "01",
),

a saved automatically as you type.( save up to limit, default to 5 )

input_history_text_field-1

a input history is suggested.

input_history_text_field-2

input history can be deleted.

input_history_text_field-3

Example

simple

All you need is a historyKey.

InputHistoryTextField(
    historyKey: "01",
),
badge style

Change style to badge is listStyle = ListStyle.Badge

InputHistoryTextField(
    historyKey: "01",
    listStyle: ListStyle.Badge,
),

 
image
Default items

If there is an item you want to display from the beginning or an item you want the user to selected.

InputHistoryTextField(
    historyKey: "01",
    lockItems: ['Flutter', 'Rails', 'React', 'Vue'],
),

List
image
change icon

Can hide or change the icon.

InputHistoryTextField(
    historyKey: "01",
    showHistoryIcon: true,
    showDeleteIcon: true,
    historyIcon: Icons.add,
    deleteIcon: Icons.delete,
),
 
image
gradually transmitted

enableOpacityGradient is input history list is gradually transmitted.

InputHistoryTextField(
    historyKey: "01",
    enableOpacityGradient: true,
),
 
image
lines decoration

listRowDecoration is input history lines as a decoration.

InputHistoryTextField(
    historyKey: "01",
    listRowDecoration: BoxDecoration(
        border: Border(
        left: BorderSide(color: Colors.blue, width: 8),
        ),
    ),
),

 
image
list decoration

listDecoration is input history list as a decoration.

InputHistoryTextField(
    historyKey: "01",
    listDecoration: BoxDecoration(
        color: Colors.cyan,
        borderRadius: BorderRadius.only(
            bottomLeft: Radius.circular(20),
            bottomRight: Radius.circular(20)),
        boxShadow: [
        BoxShadow(
            color: Colors.grey.withOpacity(0.2),
            spreadRadius: 8,
            blurRadius: 8,
            offset: Offset(0, 3)),
        ],
    ),
),

 
image
list layout builder

If you want to customize everything, to use historyListItemLayoutBuilder.

InputHistoryTextField(
    historyKey: "01",
    historyListItemLayoutBuilder: (controller, value, index) {
        return InkWell(
        onTap: () => controller.select(value.text),
        child: Row(
            children: [
            Expanded(
                flex: 1,
                child: Container(
                    margin: const EdgeInsets.only(left: 10.0),
                    padding: const EdgeInsets.only(left: 10.0),
                    decoration: BoxDecoration(
                    border: Border(
                        left: BorderSide(
                        width: 5.0,
                        color: index % 2 == 0
                            ? Colors.red
                            : Colors.blue,
                        ),
                    ),
                    ),
                    child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                        Text(
                        value.textToSingleLine,
                        overflow: TextOverflow.ellipsis,
                        style:
                            TextStyle(fontWeight: FontWeight.bold),
                        ),
                        Text(
                        DateTime.fromMillisecondsSinceEpoch(
                                value.createdTime)
                            .toUtc()
                            .toString(),
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                            fontSize: 10,
                            color: Theme.of(context).disabledColor),
                        ),
                    ],
                    )),
            ),
            IconButton(
                icon: Icon(
                Icons.close,
                size: 16,
                color: Theme.of(context).disabledColor,
                ),
                onPressed: () {
                controller.remove(value);
                },
            ),
            ],
        ),
    );}
)
 
image
API
name ex note
historyKey key-01 String a only key in the your application,saved with this key.
limit 5 int max limit of input history
hasFocusExpand true bool show input history of edit text focused
showHistoryIcon true bool icon of input history at left positioned
showDeleteIcon true bool icon of delete at right positioned
enableHistory true bool enabled/disabled of input history
enableSave true bool enabled/disabled saved history
enableOpacityGradient true bool make the input history list gradually transparent
enableFilterHistory true bool suggest filters when input text
showHistoryList true bool show/hide of input history list
historyIcon Icons.add IconData IconData for history icon.
historyIconTheme IconTheme IconTheme IconTheme for history icon.
deleteIcon Icons.delete IconData IconData for delete icon.
deleteIconTheme IconTheme IconTheme IconTheme for delete icon.
listOffset Offset(0, 5) Offset set a position for list.
listTextStyle TextStyle(fontSize: 30) TextStyle sets a text style for list.
listRowDecoration BoxDecoration Decoration a row of input history for decoration
listDecoration BoxDecoration Decoration a list of input history for decoration
listStyle ListStyle.List ListStyle change style List or Badge
textColor Colors.black Color a text color
backGroundColor Colors.grey Color a background color
historyIconColor Colors.white Color a history icon color
deleteIconColor Colors.white Color a delete icon color
lockItems ['Flutter', 'Rails', 'React', 'Vue'] List
fixed shown, cannot be delete items
lockTextColor Colors.black Color a lock items text color
lockBackgroundColor Colors.grey Color a lock items background color
historyListItemLayoutBuilder Widget Widget a customize full layout.
InputHistoryController InputHistoryController InputHistoryController Select or delete the input history list

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。