搜尋套件、儲存庫與 APP 分類

multiselect_formfield 封面
套件詳情v0.1.7

multiselect_formfield

使用警示對話方塊選擇多個項目(帶複選框),並以晶片形式顯示的多選表單欄位。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
2360
喜歡數
139
Pub 分數
130

安裝套件

flutter pub add multiselect_formfield

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,提供使用帶有核取方塊的警示對話方塊進行多選表單欄位。已選項目以晶片形式顯示,提供一種乾淨且具互動性的方法來處理表單中的多項選擇。該套件支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。此套件透過結合直覺式選擇與晶片提供的視覺反饋,提升使用者體驗,非常適合用於篩選、標籤或偏好式輸入。

適用情境

  • 需要多個選擇的表單輸入
  • 標籤系統
  • 儀表板中的篩選選項
  • 使用者偏好收集
  • 多選調查
  • 動態類別選擇

主要特色

  • 帶複選框的警告對話框
  • 晶片顯示所選項目
  • 跨平台支援
  • 可自訂的對話框標題和按鈕
  • 與 Form 小部件的輕鬆整合
  • 支援空值安全性

適合對象

  • 開發人員建構包含多個選項的表單
  • 需要標籤或篩選功能的應用
  • 需要直覺的多選使用者介面的專案
  • 使用 Flutter 開發網頁和桌面應用的團隊
  • 以使用者體驗為導向的應用程式,帶有互動式表單

使用建議

  • 可能需要為複雜主題自訂樣式
  • 對話在小螢幕上可能會造成干擾
  • 複選框外觀的自訂選項有限
  • 不適用於非常大的項目列表
  • 需要手動處理初始值
  • 最適合與中等數量的可選項目一起使用

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Donate - Buy Me A Coffee

Multi select form field

A multi select form field using alert dialog to select multiple items with checkboxes and showing as chips.

Demo

Features

  • Can be used as regular form field.
  • Simple to implement.
  • Simple and intuitive to use in the app.
  • Provides validation of data.
  • Provides requirement of the field.
  • Customizable texts.
  • Follows the app theme and colors.
  • Upgraded to Null Safety.
Customization Parameters [MultiFormField]
Parameter Description
title Widget Set Title of MultiSelectTextFormField.
hintWidget Widget Set Hint Text of MultiSelectTextFormField.
required bool Add Selection is Compulsary or not.
errorText String Error String to be Displayed
dataSource List List of Data as DataSource To Select.
textField String Key Param from List (DataSource).
valueField String Value Param From List (DataSource).
okButtonLabel String* POsitive Button Label String.
cancelButtonLabel String* Negative Button Label String.
fillColor Color Widget Changes background color of FormField
Customization [Selection Dialog]
Parameter Description
Shape ShapeBorder Customizes the Shape Of AlertDialog
dialogTextStyle TextStyle Customizes the TextStyle Of AlertDialog
checkBoxCheckColor Color Customizes the CheckColor
checkBoxActiveColor Color Customizes the CheckBoxActiveColor
Customization [Selection Chip]
Parameter Description
chipLabelStyle TextStyle Customizes the TextStyle Of Selected Chip
chipBackGroundColor Color Customizes the Color Of Selected Chip

Minimal Example

MultiSelectFormField(
                  autovalidate: false,
                  chipBackGroundColor: Colors.red,
                  chipLabelStyle: TextStyle(fontWeight: FontWeight.bold),
                  dialogTextStyle: TextStyle(fontWeight: FontWeight.bold),
                  checkBoxActiveColor: Colors.red,
                  checkBoxCheckColor: Colors.green,
                  dialogShapeBorder: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(12.0))),
                  title: Text(
                    "Title Of Form",
                    style: TextStyle(fontSize: 16),
                  ),
                  dataSource: [
                    {
                      "display": "Running",
                      "value": "Running",
                    },
                    {
                      "display": "Climbing",
                      "value": "Climbing",
                    },
                    {
                      "display": "Walking",
                      "value": "Walking",
                    },
                  ],
                  textField: 'display',
                  valueField: 'value',
                  okButtonLabel: 'OK',
                  cancelButtonLabel: 'CANCEL',
                  hintWidget: Text('Please choose one or more'),
                  initialValue: _myActivities,
                  onSaved: (value) {
                    if (value == null) return;
                    setState(() {
                      _myActivities = value;
                    });
                  },
                ),

Example

import 'package:flutter/material.dart';
import 'package:multiselect_formfield/multiselect_formfield.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List? _myActivities;
  late String _myActivitiesResult;
  final formKey = new GlobalKey<FormState>();

  @override
  void initState() {
    super.initState();
    _myActivities = [];
    _myActivitiesResult = '';
  }

  _saveForm() {
    var form = formKey.currentState!;
    if (form.validate()) {
      form.save();
      setState(() {
        _myActivitiesResult = _myActivities.toString();
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('MultiSelect Formfield Example'),
      ),
      body: Center(
        child: Form(
          key: formKey,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              Container(
                padding: EdgeInsets.all(16),
                child: MultiSelectFormField(
                  autovalidate: AutovalidateMode.disabled,
                  chipBackGroundColor: Colors.blue,
                  chipLabelStyle: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),
                  dialogTextStyle: TextStyle(fontWeight: FontWeight.bold),
                  checkBoxActiveColor: Colors.blue,
                  checkBoxCheckColor: Colors.white,
                  dialogShapeBorder: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(12.0))),
                  title: Text(
                    "My workouts",
                    style: TextStyle(fontSize: 16),
                  ),
                  validator: (value) {
                    if (value == null || value.length == 0) {
                      return 'Please select one or more options';
                    }
                    return null;
                  },
                  dataSource: [
                    {
                      "display": "Running",
                      "value": "Running",
                    },
                    {
                      "display": "Climbing",
                      "value": "Climbing",
                    },
                    {
                      "display": "Walking",
                      "value": "Walking",
                    },
                    {
                      "display": "Swimming",
                      "value": "Swimming",
                    },
                    {
                      "display": "Soccer Practice",
                      "value": "Soccer Practice",
                    },
                    {
                      "display": "Baseball Practice",
                      "value": "Baseball Practice",
                    },
                    {
                      "display": "Football Practice",
                      "value": "Football Practice",
                    },
                  ],
                  textField: 'display',
                  valueField: 'value',
                  okButtonLabel: 'OK',
                  cancelButtonLabel: 'CANCEL',
                  hintWidget: Text('Please choose one or more'),
                  initialValue: _myActivities,
                  onSaved: (value) {
                    if (value == null) return;
                    setState(() {
                      _myActivities = value;
                    });
                  },
                ),
              ),
              Container(
                padding: EdgeInsets.all(8),
                child: ElevatedButton(
                  child: Text('Save'),
                  onPressed: _saveForm,
                ),
              ),
              Container(
                padding: EdgeInsets.all(16),
                child: Text(_myActivitiesResult),
              )
            ],
          ),
        ),
      ),
    );
  }
}

License

This project is licensed under the BSD License. See the LICENSE file for details.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。