flutter_smart_forms 1.0.2 copy "flutter_smart_forms: ^1.0.2" to clipboard
flutter_smart_forms: ^1.0.2 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 #

pub package likes popularity pub points license

flutter_smart_forms is a powerful, reactive, and dynamic JSON-driven form builder for Flutter.

It allows developers to create complex forms in minutes with built-in validation, conditional fields, async validation, file uploads, dynamic arrays, barcode scanning, signature capture, and more.

Perfect for:

  • Admin dashboards
  • CMS-driven forms
  • Enterprise applications
  • Survey apps
  • Workflow systems
  • Dynamic configuration based forms

๐Ÿ“ธ Demo #

Validation Demo #

[Validation]

JSON Dynamic Form #

[Dynamic JSON Form]

Complex JSON Form Layout #

[Dynamic JSON Form Example]

File & Image Upload #

[File Upload]

[Dropdown Demo]

Stepper Form Example #

[Stepper Demo]


โœจ 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
  • โœ… Stepper form
  • โœ… 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

๐Ÿ“ฑ Supported Platforms #

  • โœ… Android
  • โœ… iOS
  • โœ… Web
  • โœ… Windows
  • โœ… macOS
  • โœ… Linux

Why flutter_smart_forms? #

flutter_smart_forms simplifies building complex dynamic forms in Flutter.

Forms can be defined using:

  • JSON configuration
  • FieldModel objects
  • Native Flutter widgets

This makes it ideal for:

โ€ข Admin dashboards โ€ข CMS driven apps โ€ข Enterprise applications โ€ข Dynamic form APIs

๐Ÿ“Š Comparison #

Feature flutter_smart_forms flutter_form_builder reactive_forms
JSON Forms โœ… โŒ โŒ
Conditional Fields โœ… โš ๏ธ โš ๏ธ
Async Validation โœ… โš ๏ธ โš ๏ธ
Dynamic Arrays โœ… โš ๏ธ โš ๏ธ
Barcode Scanner โœ… โŒ โŒ
Signature Field โœ… โŒ โŒ
File Upload โœ… โš ๏ธ โŒ

๐Ÿ— Architecture #

flutter_smart_forms uses a modular architecture.

JSON Schema
     โ”‚
     โ–ผ
FieldModel Parser
     โ”‚
     โ–ผ
FormRegistry
     โ”‚
     โ–ผ
SmartFormController
     โ”‚
     โ–ผ
Reactive Field Widgets
     โ”‚
     โ–ผ
Validation Engine
     โ”‚
     โ–ผ
Submit Result

โšก JSON-Driven Dynamic Forms #

Create entire forms using JSON configuration.

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

๐Ÿง  Reactive Form Controller #

SmartFormController manages:

  • Field values
  • Validation
  • Visibility
  • Dependencies
  • Async validation
  • Form reset
  • Value listeners
  • Conditional fields

๐Ÿงฉ Built-in Field Types #

Field Description
text Basic text input
email Email input
password Secure password field
phone Phone number input
textarea Multi-line input
number Numeric input
dropdown Single select dropdown
multiSelect Multi select dropdown
suggestion Auto-complete field
checkbox Boolean checkbox
radio Radio options
date Date picker
time Time picker
barcode Barcode scanner
otp OTP verification
signature Signature capture
file File upload
image Image upload
array Dynamic repeatable forms

๐Ÿš€ Installation #

Add dependency in pubspec.yaml

dependencies:
  flutter_smart_forms: ^1.0.2

Install via CLI #

flutter pub add flutter_smart_forms

Then run

flutter pub get

๐Ÿš€ Getting Started #

Import the package:

import 'package:flutter_smart_forms/flutter_smart_forms.dart';

Quick Example #

SmartForm(
  controller: SmartFormController(),
  json: [
    {
      "type": "text",
      "key": "name",
      "label": "Name",
      "validators": "required"
    }
  ],
  onSubmit: (values) {
    print(values);
  },
)

๐Ÿ“Œ Basic Usage #

1๏ธโƒฃ Create Controller #

final controller = SmartFormController();

2๏ธโƒฃ Build Form #

SmartForm(
  controller: controller,
  json: jsonForm,
  submitText: "Submit",
  onSubmit: (values) async {
    print(values);
  },
)

1๏ธโƒฃ Create Controller With Draft Key #

final controller = SmartFormController(
  draftKey: "profile_form_draft",
  autoSaveDraft: true,
);

2๏ธโƒฃ Restore Draft When Screen Opens #

@override
void initState() {
  super.initState();

  controller.restoreDraft();
}

Now if user previously filled the form, values will auto populate.


3๏ธโƒฃ Save Draft Manually #

If autoSaveDraft = false, save manually.

ElevatedButton(
  onPressed: () async {
    await controller.saveDraft();

    ScaffoldMessenger.of(context).showSnackBar(
      const SnackBar(content: Text("Draft saved")),
    );
  },
  child: const Text("Save Draft"),
)

4๏ธโƒฃ Auto Save Draft (Recommended) #

SmartFormController(
  draftKey: "profile_form_draft",
  autoSaveDraft: true,
);

5๏ธโƒฃ Clear Draft #

await controller.clearDraft();

6๏ธโƒฃ How to Access Draft #

final draft = await controller.getDraft();

if (draft != null) {
  print(draft);
}

7๏ธโƒฃ If has Draft #

if (await controller.hasDraft()) {
  print("Draft exists");
}
Method Purpose
saveDraft() Save current form values
restoreDraft() Load draft into form
clearDraft() Delete stored draft
getDraft() Read draft without restoring
hasDraft() Check if exists

๐Ÿ“„ JSON Form Example #

[
  {
    "type": "text",
    "key": "firstName",
    "label": "First Name",
    "validators": "required|min:2"
  },
  {
    "type": "email",
    "key": "email",
    "label": "Email",
    "validators": "required|email"
  },
  {
    "type": "password",
    "key": "password",
    "label": "Password",
    "validators": "required|min:6"
  },
  {
    "type": "password",
    "key": "confirmPassword",
    "label": "Confirm Password",
    "validators": "required|match:password"
  }
]

๐ŸŒ Remote API Dropdown #

flutter_smart_forms supports dynamic dropdown data loaded from API.

{
  "type": "dropdown",
  "key": "country",
  "label": "Select Country",
  "extra": {
    "api": "https://api.restful-api.dev/objects",
    "method": "GET",
    "valueKey": "id",
    "labelKey": "name",
    "cache": true,
  }
},
{
  "type": "dropdown",
  "key": "devices",
  "label": "Devices",
  "extra": {
    "multiSelect": true,
    "api": "https://api.restful-api.dev/objects",
    "labelKey": "name",
    "valueKey": "id",
    "cache": true,
    'selectedChipTextColor': '0xFFFFFFFF',
  }
},

Flutter Smart Form Stepper Example #

This example demonstrates how to use the SmartFormStepper widget with section titles displayed correctly.


JSON Sections Example #

final jsonSections = [
  {
    "title": "Personal",
    "fields": [
      {
        "type": "text",
        "key": "firstName",
        "label": "First Name",
        "placeholder": "Enter first name",
        "default": "Johna",
        "validators": "required|min:2",
        "extra": {
          "fillColor": "0xFFFFFFFF",
          "borderColor": "#1976D2",
          "borderRadius": 12,
          "padding": {"left": 16, "top": 12, "right": 16, "bottom": 12},
          "textColor": "#000000",
        }
      },
      {
        "type": "text",
        "key": "lastName",
        "label": "Last Name",
        "placeholder": "Enter last name",
        "validators": "required",
        "extra": {
          "fillColor": "0xFFFFFFFF",
          "borderColor": "#1976D2",
          "borderRadius": 12,
          "padding": {"left": 16, "top": 12, "right": 16, "bottom": 12},
        }
      }
    ]
  },
  {
    "title": "Scan & Date",
    "fields": [
      {
        "type": "barcode",
        "key": "barcode",
        "label": "Scan Product",
        "placeholder": "Scan or enter barcode",
        "validators": "required",
        "extra": {
          "scannerTitle": "Barcode Scan",
          "scannerAppBarColor": "#1976D2",
          "showClearIcon": true,
          "clearIcon": "close",
          "fillColor": "0xFFFFFFFF",
          "borderColor": "#1976D2",
          "borderRadius": 12,
          "padding": {"left": 16, "top": 12, "right": 16, "bottom": 12},
        }
      },
      {
        "type": "date",
        "key": "birthday",
        "label": "Select Birthday",
        "extra": {
          "placeholder": "Pick a date",
          "format": "dd/MM/yyyy",
          "fillColor": "0xFFFFFFFF",
          "borderRadius": 10,
          "padding": {"left": 12, "top": 10, "right": 12, "bottom": 10},
        }
      }
    ]
  }
];

Widget buildStepperForm() {
  final convertedSections = JsonFormBuilder.fromJsonSections(jsonSections);
  return SmartFormStepper(
    controller: controller,
    field: FieldModel(type: "stepper", key: "mainStepper", extra: {}, label: ''),
    sections: convertedSections,
    onSubmit: (data) {
      print(data);
    },
  );
}

๐Ÿง  Access Form Values #

final values = controller.values;

print(values["email"]);

๐Ÿ” Validate Form #

bool valid = await controller.validate();

Get value #

controller.getValue("email");

๐Ÿ”„ Update Field Value #

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

๐Ÿ”„ Reset Form #

controller.reset();

๐Ÿ”„ Export Analytics #

final analytics = controller.analytics.export();

print(analytics);

๐Ÿ‘€ Listen to Form Changes #

controller.changes.listen((values) {
  print(values);
});

๐Ÿ”„ Conditional Fields #

Fields can react to other fields.

Example JSON:

{
  "type": "text",
  "key": "lastName",
  "label": "Last Name",
  "visibleIf": {
    "firstName": "John"
  }
}

๐Ÿงช Async Validation #

Register async validator:

AsyncValidationEngine.register(
  "emailAvailable",
  (value) async {
    await Future.delayed(Duration(milliseconds: 500));

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

    return null;
  },
);

Use in JSON:

validators: "required|email|async:emailAvailable"

๐Ÿงฉ Custom Field Support #

Register custom field widget.

FormRegistry.register(
  "colorPicker",
  (field, controller) => ColorPickerField(
    field: field,
    controller: controller,
  ),
);

JSON usage:

{
  "type": "colorPicker",
  "key": "favoriteColor"
}

๐Ÿ–ผ File & Image Upload #

Features:

  • Multiple file upload
  • Image preview
  • File validation
  • Image compression
  • Cropping
  • File size limit
  • Allowed extensions

โœ Signature Field #

Capture user signature.

Features:

  • Draw signature
  • Undo / clear
  • Preview
  • Save as image
  • Fullscreen canvas

๐Ÿ“ท Barcode Scanner #

Scan barcodes using device camera.

Features:

  • Multi scan support
  • Duplicate prevention
  • Scan delay
  • Pattern validation

๐Ÿ”ข OTP Input #

Highly customizable OTP input field.

Options:

  • Length
  • Box size
  • Spacing
  • Auto focus
  • Obscure input
  • Success animation

โš™๏ธ Conditional Logic #

Fields can depend on other fields.

Example:

{
  "type": "dropdown",
  "key": "state",
  "watchFields": ["country"],
  "visibleIf": { "country": "US" }
}

๐ŸŽจ Styling Fields #

Customize styles via JSON.

{
  "type": "text",
  "key": "name",
  "extra": {
    "fillColor": "#FFFFFF",
    "borderColor": "#1976D2",
    "borderRadius": 12
  }
}

๐Ÿ“ฆ Built-in Validators #

Validator Description
required Required field
email Email validation
phone Phone number validation
min Minimum length
max Maximum length
number Only numbers
integer Integer values
decimal Decimal values
url URL validation
regex Regex validation
password Strong password
date Date validation
json JSON validation
alpha Letters only
alphaNumeric Letters + numbers

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

๐Ÿ”— Cross Field Validators #

Validator Description
match Must match another field
same Same as another field
different Must be different
confirmed Confirmation field

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"
  }
}

๐Ÿงช Example Project #

Example app included.

example/lib/main.dart

Run example:

flutter run

๐Ÿ›ฃ Roadmap #

Upcoming features:

  • Multi-step forms
  • Form wizard
  • Remote dropdown APIs
  • JSON schema support
  • Form persistence
  • Visual form builder
  • Analytics support

๐Ÿค Contributing #

Contributions are welcome.

Steps:

  1. Fork repository
  2. Create branch
  3. Commit changes
  4. Submit pull request

๐Ÿ“œ License #

MIT License


โค๏ธ Support #

If you like this package:

โญ Star the repository
๐Ÿ› Report issues
๐Ÿ’ก Suggest improvements


Maintainers #

Raju
Flutter Developer


๐Ÿ”Ž Keywords #

Flutter dynamic form
Flutter JSON form builder
Flutter dynamic forms
Flutter form generator
Flutter reactive forms
Flutter low code forms
Flutter survey forms
Flutter conditional forms
Flutter async validation forms

1
likes
140
points
270
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, http, image_picker, intl, mobile_scanner, multi_select_flutter, path_provider, pinput, shared_preferences, signature

More

Packages that depend on flutter_smart_forms