パッケージ、リポジトリ、アプリカテゴリを検索

easy_formz のカバー
パッケージ詳細v1.1.4

easy_formz

より簡単なフォームジェネレーター操作を可能にする Flutter プラグイン。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
50
いいね数
4
Pub ポイント
150

パッケージをインストール

flutter pub add easy_formz

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Easy Formz は、フォームの生成と検証を簡素化するためのFlutterパッケージです。フォーム状態、検証ルール、送信ロジックの管理に直感的なAPIを提供することで、ボイラープレートコードを削減し、開発者の生産性を向上させます。Dartで構築されており、Android、iOS、Web、macOS、Windows、Linuxなど、複数のプラットフォームに対応するFlutterアプリケーションにシームレスに統合できます。不変データ構造とリアクティブパターンを活用することで、クリーンで保守可能なコードを促進します。最小限の努力で堅牢かつスケーラブルなフォームを構築したい開発者にとって特に有用です。

用途

  • 最小限のボイラープレートでフォームを作成
  • リアクティブフォーム状態管理
  • クロスプラットフォームフォーム実装
  • 複雑な検証ロジックの処理
  • スムーズなフォーム送信ワークフロー

主な機能

  • 変更不可能なフォーム状態
  • 組み込みの検証ユーティリティ
  • リアクティブフォームの更新
  • カスタムバリデーターのサポート
  • Flutter ウィジェットとの簡単な統合

適している対象

  • 複雑なフォームを構築する開発者
  • コードの保守性を重視するチーム
  • クロスプラットフォームのフォームの一貫性を必要とするプロジェクト
  • 厳格な検証要件を持つアプリケーション
  • Flutter 初心者がフォーム処理を学習中

注意事項

  • リアクティブプログラミングのコンセプトを理解している必要があります
  • 高度な検証シナリオのための追加設定が必要になる場合があります
  • Bloc や Provider のような状態管理ソリューションを使用するプロジェクトに最適
  • 基本的な例以外のドキュメントは限られている
  • 非常に単純なワンタイムフォームには適していない

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

EasyFormz Package

The purpose of this package is to facilitate the creation of dynamic forms based on data received from the server. The package provides several basic components, including form types such as 'input', 'textarea', 'dropdown', 'checkbox', 'multicheckbox', 'radio', 'date', and 'time'. Additionally, users have the flexibility to create custom forms if none of the predefined form types suit their needs.

The example app running in iOS

Table of Contents

Available Form Types

  1. Input: Single-line text input.
  2. Textarea: Multi-line text input.
  3. Dropdown: Dropdown selection.
  4. Checkbox: Single checkbox.
  5. Multicheckbox: Multiple checkboxes.
  6. Radio: Radio button selection.
  7. Date: Date picker for selecting a date.
  8. Time: Time picker for selecting a time.

Using the EasyFormz Widget

To integrate the package into your Flutter application, follow these steps:

  1. Add the EasyFormz widget to your widget tree:

    EasyFormz(controller: controller)
    
  2. Initialize the form controller with the desired form data & Keep your UI in sync by listening to changes on the form controller. Example:

     late final EasyFormzController controller = EasyFormzController(forms: forms);
    
     @override
     Widget build(BuildContext context) {
       return Scaffold();
     }
    

    The forms data should be look like this

    final forms = [
     FormConfig(
       id: '412',
       type: 'input',
       formKey: 'dynamic_input_key',
       label: 'Test Form Input',
       props: FormProps(isRequired: true),
     ),
      FormConfig(
       id: '702',
       type: 'dropdown',
       formKey: 'dynamic_dropdown_key',
       label: 'Test Form Dropdown',
       props: FormProps(
         isRequired: true,
         options: [
           FormOption(label: 'Option One', value: 'ONE'),
           FormOption(label: 'Option Two', value: 'TWO'),
           FormOption(label: 'Option Three', value: 'Three'),
         ],
       ),
     ),
     FormConfig(
       id: '432',
       type: 'radio',
       formKey: 'dynamic_radio_key',
       label: 'Test Form Radio',
       props: FormProps(
         isRequired: false,
         options: [
           FormOption(label: 'Option One', value: 'ONE'),
           FormOption(label: 'Option Two', value: 'TWO'),
           FormOption(label: 'Option Three', value: 'THREE'),
         ],
       ),
     ),
     FormConfig(
       id: '612',
       type: 'checkbox',
       formKey: 'dynamic_checkbox_key',
       label: 'Test Form Checkbox',
       props: FormProps(
         isRequired: false,
         options: [
           FormOption(label: 'Option One', value: 'ONE'),
           FormOption(label: 'Option Two', value: 'TWO'),
           FormOption(label: 'Option Three', value: 'THREE'),
         ],
       ),
     ),
     FormConfig(
       id: '612',
       type: 'textarea',
       formKey: 'dynamic_textarea_key',
       label: 'Test Form Text Area',
       props: FormProps(isRequired: true),
     ),
     FormConfig(
       id: '232',
       type: 'checkbox',
       formKey: 'dynamic_checkboxNoOption_key',
       label: 'Test Form Checkbox No Option',
       props: FormProps(isRequired: true),
     ),
     FormConfig(
       id: '132',
       type: 'multicheckbox',
       formKey: 'dynamic_multiCheckbox_key',
       label: 'Test Form MultiCheckbox',
       props: FormProps(
         isRequired: true,
         options: [
           FormOption(label: 'Option One', value: 'ONE'),
           FormOption(label: 'Option Two', value: 'TWO'),
           FormOption(label: 'Option Three', value: 'THREE'),
         ],
       ),
     ),
     FormConfig(
       id: '162',
       type: 'date',
       formKey: 'dynamic_date_key',
       label: 'Test Form Date',
       props: FormProps(isRequired: false),
     ),
     FormConfig(
       id: '164',
       type: 'time',
       formKey: 'dynamic_time_key',
       label: 'Test Form Time',
       props: FormProps(isRequired: true),
     ),
    ];
    
  3. Let's say you have a list of form page then you can do like the following example:

    final formPages = [
        FormPage(
             id: 'gweorj29',
             label: 'Example Page 1',
             description: 'This form displays all the existing forms available',
             formConfigs: forms1,
         ),
            FormPage(
             id: 'gweorj29',
             label: 'Example Page 2',
             description: 'This form displays all the existing forms available',
             formConfigs: forms2,
         ),
    ];
    

    To diplay all the form pages as a ListTile

    ListView.separated(
         itemCount: formPages.length,
         separatorBuilder: (context, index) {
           return const SizedBox(height: 16);
         },
         itemBuilder: (context, index) {
           final form = formPages[index];
    
           return Card(
             margin: const EdgeInsets.symmetric(horizontal: 16),
             clipBehavior: Clip.antiAlias,
             child: ListTile(
               onTap: () {
                 Navigator.push(
                   context,
                   MaterialPageRoute(
                     builder: (context) => FormScreen(form: form),
                   ),
                 );
               },
               title: Text(
                 form.label,
                 style: Theme.of(context).textTheme.titleMedium,
               ),
               subtitle: Text(
                 form.description,
                 style: Theme.of(context).textTheme.bodySmall,
               ),
             ),
           );
         },
       ),
    

    Inside the FormScreen get the form parameter like the following example:

     late final EasyFormzController controller = EasyFormzController(forms: widget.form.formConfigs);
    
     @override
     Widget build(BuildContext context) {
       return Scaffold();
     }
    

Custom Form Creation

In scenarios where the provided form types do not meet specific requirements, users can easily create custom forms tailored to their needs.

Basic Component Builder

To change any in-built form component such as inputBuilder, etc, consider the following example:

EasyFormz(
controller: controller,
inputBuilder: (config, onValueChanged) => Padding(
 padding: const EdgeInsets.all(16),
 child: TextFormField(
   onChanged: (value) {
     onValueChanged(value);
   },
 ),
),
);
Custom Form Component Builder

To create a custom form component based on the form configuration using the customBuilder, consider the following example:

EasyFormz(
  controller: controller,
  customBuilder: (config, onValueChanged) {
    if (config.type == 'custom_form') {
      // Customize and return the specific custom form component based on the condition.
      return CustomDropdown(
        config: config,
        onChanged: (value) => onValueChanged(value),
      );
    }
  },
);
Custom Error Component Builder

Custom error component is available by using the errorBuilder, consider the following example:

EasyFormz(
  controller: controller,
  errorBuilder: (config) {
    return CustomErrorBox(
        label: '${config.label} cannot be rendered',
      );
  },
);
Customizing the Easy Form Theme

To personalize the appearance of the dynamic form, you can modify the theme settings using the theme parameter. Below is an example of customizing the theme for a EasyFormz:

EasyFormz(
  controller: controller,
  theme: EasyFormzTheme()
)

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or bug fixes.

License

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

Support Me

If you find this package helpful and want to support its development, consider making a donation. Thank you for your support!

Support via PayPal

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。