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

select_form_field 封面
插件详情v2.2.0

select_form_field

一个 Flutter 选择表单字段小部件。它在下拉菜单中显示选项列表。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
781
喜欢数
87
Pub 分数
130

安装插件

flutter pub add select_form_field

插件介绍

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

一个 Flutter 小部件,实现了一个带有下拉菜单的表单字段,用于选择选项。它提供了一个简洁、可自定义的界面,便于从一组值中进行选择,非常适合需要用户从预定义选项中输入的表单。该小部件支持 Android、iOS、Web、macOS、Windows 和 Linux 等多种平台,确保跨平台的一致性。它可以无缝集成到现有表单中,并可按应用主题进行样式定制。

适合场景

  • 带有预定义选项的表单输入
  • 用户从列表中选择
  • 跨平台下拉字段
  • 动态选项加载
  • 可自定义的下拉菜单样式
  • 与表单验证集成

主要特点

  • 下拉菜单界面
  • 可自定义外观
  • 平台无关设计
  • 与表单的轻松集成
  • 支持空安全
  • 可配置的选项显示

适合对象

  • 在 Flutter 中构建表单的开发者
  • 需要用户从列表中进行选择的应用程序
  • 需要跨平台一致 UI 的项目
  • 注重代码复用的团队
  • 具有动态或静态选项集的应用程序

使用建议

  • 需要手动处理选项更新
  • 有限的内置过滤功能
  • 复杂设计可能需要额外的样式
  • 未针对非常大的选项列表进行优化
  • 依赖外部依赖项以实现高级功能

原始 README

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

select_form_field

pub package

Buy Me A Beer

A Flutter select field widget. It shows a list of options in a dropdown menu.
This widget extend TextField and has a similar behavior as TextFormField

Usage

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  select_form_field: "^2.2.0"

In your library add the following import:

import 'package:select_form_field/select_form_field.dart';

For help getting started with Flutter, view the online documentation.

Example

Set items using a List map passing:

  • value: [String],
  • textStyle: [TextStyle | null],
  • label: [String | null],
  • icon: [Widget | null],
  • enable: [bool | null],
final List<Map<String, dynamic>> _items = [
  {
    'value': 'boxValue',
    'label': 'Box Label',
    'icon': Icon(Icons.stop),
  },
  {
    'value': 'circleValue',
    'label': 'Circle Label',
    'icon': Icon(Icons.fiber_manual_record),
    'textStyle': TextStyle(color: Colors.red),
  },
  {
    'value': 'starValue',
    'label': 'Star Label',
    'enable': false,
    'icon': Icon(Icons.grade),
  },
];
SelectFormField(
  type: SelectFormFieldType.dropdown, // or can be dialog
  initialValue: 'circle',
  icon: Icon(Icons.format_shapes),
  labelText: 'Shape',
  items: _items,
  onChanged: (val) => print(val),
  onSaved: (val) => print(val),
);

The result of val in onChanged, validator and onSaved will be a String.
So, if you tap on Box Label item on select menu the result will be boxValue.

Preview

Overview

所属分类

源码仓库

使用此插件的项目

暂无相关数据。