搜尋套件、儲存庫與 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

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。