flutter_smart_forms 1.0.1 copy "flutter_smart_forms: ^1.0.1" to clipboard
flutter_smart_forms: ^1.0.1 copied to clipboard

PlatformiOS

A powerful reactive JSON-driven form builder for Flutter with validation, async validation, conditional fields, dynamic UI, file upload, image upload, nested arrays, and extensible architecture.

🌟 flutter_smart_forms #

Flutter Smart Forms is a powerful, reactive, and dynamic form builder for Flutter that allows developers to build complex forms using JSON or Flutter widgets with minimal boilerplate.

It includes validation, async validation, conditional fields, icons, dynamic visibility, showClearIcon inputs, and reactive state management.

Build powerful forms once and control them dynamically through APIs or JSON.


πŸ“Έ Demo #

JSON Dynamic Form #

[Dynamic JSON Form]

Complex JSON Form Layout #

[Dynamic JSON Form Example]

File & Image Upload #

[File Upload]

Validation Demo #

[Validation]

[Dropdown Demo]


⚑ 30 Second Example #

Create a fully working form in seconds.

import 'package:flutter_smart_forms/flutter_smart_forms.dart';

final controller = SmartFormController();

SmartForm(
  controller: controller,
  children: [

    TextFieldField(
      "name",
      label: "Full Name",
      showClearIcon: true,
    ),

    EmailField(
      "email",
      label: "Email Address",
    ),

    PasswordField(
      "password",
      label: "Password",
    ),

    DropdownField(
      "country",
      label: "Country",
      items: ["India", "USA", "UK"],
    ),

  ],
  onSubmit: (values) {
    print(values);
  },
);

Result

{
"name": "John",
"email": "john@email.com",
"password": "****",
"country": "India"
}

✨ Features #

  • βœ… JSON-driven forms
  • βœ… Widget-driven forms
  • βœ… Reactive field updates
  • βœ… Real-time value tracking
  • βœ… Synchronous validation
  • βœ… Async validation
  • βœ… Conditional field visibility
  • βœ… Enable / disable fields dynamically
  • βœ… Readonly fields
  • βœ… showClearIcon input fields
  • βœ… Date / Time / DateTime picker support
  • βœ… Icon support
  • βœ… Nested array support
  • βœ… File / Image upload support
  • βœ… Signature pad
  • βœ… Barcode scanner
  • βœ… Fully customizable UI
  • βœ… Simple developer API
  • βœ… Extendable architecture

Why flutter_smart_forms? #

flutter_smart_forms simplifies building complex dynamic forms in Flutter.

Instead of writing hundreds of lines of UI code, forms can be defined using:

β€’ JSON β€’ FieldModel β€’ Flutter widgets

This makes it ideal for:

β€’ Admin dashboards β€’ CMS driven apps β€’ Enterprise applications β€’ Dynamic form APIs

Feature flutter_smart_forms flutter_form_builder reactive_forms
JSON driven forms βœ… ❌ ❌
Conditional fields βœ… ⚠️ ⚠️
Async validation βœ… βœ… βœ…
File upload βœ… ❌ ❌
Signature pad βœ… ❌ ❌
Nested arrays βœ… ⚠️ ⚠️

Architecture Diagram #

JSON / Widgets
      ↓
FieldModel
      ↓
SmartFormController
      ↓
Reactive Fields
      ↓
UI Rendering

🧩 Supported Field Types #

Field Type Supported
Text βœ…
Multiline Text βœ…
Email βœ…
Phone βœ…
Password βœ…
Dropdown βœ…
Multi Select βœ…
Checkbox βœ…
Radio βœ…
Switch βœ…
Date Picker βœ…
Time Picker βœ…
DateTime Picker βœ…
File Upload βœ…
Image Upload βœ…
Suggestion / AutoComplete βœ…
Signature Pad βœ…
Barcode Scanner βœ…
Rating βœ…

More fields will be added in future releases.


πŸ“¦ Installation #

Add the package to your pubspec.yaml

dependencies:
  flutter_smart_forms: ^1.0.1

Run

flutter pub get

πŸš€ Quick Start #

Create a form using Flutter widgets.

import 'package:flutter_smart_forms/flutter_smart_forms.dart';

final formController = SmartFormController();

SmartForm(
  controller: formController,
  children: [

    TextFieldField(
      "name",
      label: "Full Name",
      showClearIcon: true,
    ),

    EmailField(
      "email",
      label: "Email Address",
    ),

    PasswordField(
      "password",
      label: "Password",
    ),

    DropdownField(
      "country",
      label: "Country",
      items: ["India", "USA", "UK"],
    ),

  ],
  onSubmit: (values) {
    print(values);
  },
);

Example output

{
  name: John,
  email: john@email.com,
  password: ****,
  country: India
}

🧠 JSON Driven Forms #

Forms can also be created dynamically using JSON.

final jsonForm = [
  {
    "type": "text",
    "key": "name",
    "label": "Full Name",
    "placeholder": "Enter your full name",
    "showClearIcon": true
  },
  {
    "type": "email",
    "key": "email",
    "label": "Email Address"
  },
  {
    "type": "password",
    "key": "password",
    "label": "Password"
  },
  {
    "type": "dropdown",
    "key": "country",
    "label": "Country",
    "items": ["India", "USA", "UK"]
  }
];

Use JSON in SmartForm

final fields = jsonForm.map((e) => FieldModel.fromJson(e)).toList();

SmartForm(
  controller: controller,
  fields: fields,
  onSubmit: (values) {
    print(values);
  },
);

🧾 FieldModel Example #

You can also define forms directly using FieldModel.

final fields = [
  FieldModel(
    type: 'text',
    key: 'firstName',
    label: 'First Name',
    placeholder: 'Enter first name',
    defaultValue: 'Alice',
    extra: {'disabled': true},
  ),

  FieldModel(
    type: 'text',
    key: 'lastName',
    label: 'Last Name',
    defaultValue: 'R',
  ),

  FieldModel(
    type: 'text',
    key: 'fullName',
    label: 'Full Name',
    defaultValueCallback: (values) {
      final first = values['firstName'] ?? '';
      final last = values['lastName'] ?? '';
      return '$first $last';
    },
  ),
];

πŸ‘ Conditional / Reactive Fields #

Show fields dynamically based on other field values.

FieldModel(
  type: "text",
  key: "company_name",
  label: "Company Name",
  visibleIf: {"user_type": "company"},
)

Reactive dependency example:

FieldModel(
  type: 'dropdown',
  key: 'state',
  watchFields: ['country'],
  visibleIf: {'country': 'US'},
)

πŸ“… Date / Time / DateTime Picker #

Control picker type using dateMode.

Supported values

date
time
datetime

Example

FieldModel(
  type: "date",
  key: "meeting_time",
  label: "Meeting Time",
  dateMode: "datetime",
)
Mode Result
date Date Picker
time Time Picker
datetime Date + Time Picker

βœ” Validation #

Widget example

EmailField(
  "email",
  validators: [
    Validators.required,
    Validators.email,
  ],
)

JSON example

{
  "type": "text",
  "key": "firstName",
  "label": "First Name",
  "validators": "required|min:2"
}

Available validators

  • required
  • required_if:userType,admin
  • required_unless:isGuest,true
  • email
  • phone
  • url
  • min:3
  • max:20
  • between:3,10
  • after:2024-01-01
  • fileType:jpg,png,pdf
  • regex
  • match:password
  • async:emailAvailable

Dependent Validators

Rule Example Meaning
same same:password Must be equal
different different:username Must NOT be equal
in in:admin,user,manager Value must be in list
not_in not_in:test,guest Value must NOT be in list
confirmed confirmed Must match field_confirmation
accepted accepted Must be true/yes/1

Smart Error Messages #

{
"type": "text",
"key": "username",
"label": "Username",
"validators": "required|min:3|max:10",
"messages": {
"required": "Username is required",
"min": "Username must be at least :min characters",
"max": "Username cannot exceed :max characters"
}
}

⏳ Async Validation #

Example checking email availability.

EmailField(
  "email",
  asyncValidator: (value) async {

    await Future.delayed(Duration(seconds: 1));

    if (value == "test@email.com") {
      return "Email already exists";
    }

    return null;
  },
)

πŸ—‚ File / Image Upload Options #

Parameter Type Description
uploadText String Upload button text
uploadIcon String Icon type: cloud / image
multiple bool Allow multiple files
compress bool Enable compression
compressQuality int Compression quality
preview bool Show preview
removable bool Allow remove
crop bool Enable crop
cropStyle String rectangle / circle
cropAspectRatio Map Example { "x":1,"y":1 }

πŸ”— Nested Arrays #

FieldModel(
  type: 'array',
  key: 'addresses',
  label: 'Addresses',
  extra: {'minItems': 1, 'maxItems': 5},
  fields: [
    FieldModel(type: 'text', key: 'street', label: 'Street'),
    FieldModel(type: 'text', key: 'city', label: 'City'),
  ],
)

Supports complex structures like:

Orders
 β”” Items
    β”” Sub Items

πŸŽ› SmartFormController #

Provides full control over form state.

Create controller

final controller = SmartFormController();

Set value

controller.setValue("name", "John");

Get value

controller.getValue("email");

Validate form

controller.validate();

Validate on button click

await controller.validateFields([
"email",
"password",
"phone"
]);
ElevatedButton(
  onPressed: () async {
    final valid = await controller.validateField("email");

    if (valid) {
      print("Email valid");
    }
  },
  child: Text("Check Email"),
)

Reset form

controller.reset();

Get all values

controller.values

Register custom validator

Validators.register("noAdmin", (value, param) {
  if (value == "admin") {
    return "Admin is not allowed";
  }
  return null;
});

🎨 Custom Submit Button #

SmartForm(
  controller: controller,
  fields: fields,
  submitText: "Create Account",
  submitButtonStyle: ElevatedButton.styleFrom(
    backgroundColor: Colors.green,
    padding: EdgeInsets.symmetric(vertical: 16),
  ),
  onSubmit: (values) {
    print(values);
  },
);

πŸ“‚ Example Project #

A full example is available inside

example/lib/main.dart

Run the example to explore all field types.


πŸ—Ί Roadmap #

Upcoming features

β€’ Multi-step wizard forms β€’ Remote API driven forms β€’ Form auto-save persistence β€’ Dynamic sections β€’ Drag & drop form builder


🀝 Contributing #

Contributions are welcome.

Steps

  1. Fork the repository
  2. Create a new feature branch
  3. Commit your changes
  4. Open a Pull Request

πŸ› Issues #

If you find a bug or want to request a feature, please open an issue in the repository.


πŸ“„ License #

MIT License


⭐ Support #

If you like this package:

  • ⭐ Star the repository
  • πŸ‘ Like the package on pub.flutter-io.cn

Your support helps the project grow.


πŸ”Ž Keywords #

Flutter dynamic forms Flutter form builder Flutter JSON forms Flutter validation Flutter dynamic form generator Flutter async validation Flutter form engine Flutter CMS forms Flutter reactive forms Flutter form builder package

2
likes
110
points
48
downloads
screenshot

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

A powerful reactive JSON-driven form builder for Flutter with validation, async validation, conditional fields, dynamic UI, file upload, image upload, nested arrays, and extensible architecture.

Repository (GitHub)
View/report issues

Topics

#form #dynamic-forms #json-forms #form-builder #flutter-form

License

MIT (license)

Dependencies

crop_your_image, file_picker, flutter, flutter_image_compress, flutter_svg, flutter_typeahead, image_picker, intl, mobile_scanner, multi_select_flutter, path_provider, pinput, signature

More

Packages that depend on flutter_smart_forms