๐ 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

Complex JSON Form Layout

File & Image Upload

Validation Demo

Dropdown Field Example

โก 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
- โ
showClearIconinput 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 | โ |
| โ | |
| 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
- 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
- Fork the repository
- Create a new feature branch
- Commit your changes
- 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.dev
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