dynamic_ui_builder 1.0.2+8
dynamic_ui_builder: ^1.0.2+8 copied to clipboard
A Flutter package to dynamically build multi-step forms from JSON.
Dynamic UI Builder #
A Flutter package to dynamically generate multi-step forms or single fields from JSON configuration. Easily build complex forms with validation, custom layouts, and plugin-based fields.
✨ Features #
- Multi-step form UI from JSON
- All standard input fields (Text, Dropdown, Checkbox, Radio, Switch, Slider, Date/Time)
- Plugin-based fields: Image Picker, File Picker, Signature Pad, Rating Bar
- Custom validation (regex, min/max, required, etc.)
- Alignment and layout customization
- Render any single field independently (without JSON)
🚀 Installation #
Add to your pubspec.yaml:
dependencies:
dynamic_ui_builder: ^1.0.2+8
Then run:
flutter pub get
🛠️ Usage #
1. Import the package #
import 'package:dynamic_ui_builder/dynamic_ui_builder.dart';
2. Define your JSON config (for a full form) #
const formJson = [
{
"type": "text",
"label": "Name",
"key": "name",
"hint": "Enter your name",
"regex": "^[a-zA-Z ]+",
"step": 0,
"required": true
},
{
"type": "signature",
"label": "Signature",
"key": "signature",
"step": 1
}
];
3. Use DynamicUiBuilder (Multi-step Form) #
DynamicUiBuilder(
jsonConfig: formJson,
onSubmit: (result) {
print(result); // result is a Map<String, dynamic>
},
)
✅ Use Single Field Without JSON #
DynamicFormField(
config: FormFieldConfig(
type: 'text',
label: 'Email',
key: 'email',
regex: r'^[^@]+@[^@]+\.[^@]+',
error: 'Invalid email',
),
onSaved: (value) => print('Saved: $value'),
)
📦 Supported Field Types #
| Type | Widget | Options/Notes |
|---|---|---|
text |
TextFormField | inputType, minLength, maxLength, regex, required |
dropdown |
DropdownButton | options, required |
radio |
RadioListTile | options, required |
checkbox |
CheckboxListTile | required |
switch |
SwitchListTile | required |
slider |
Slider | min, max, divisions, required |
date |
showDatePicker | minDate, maxDate, required |
time |
showTimePicker | required |
image |
image_picker | |
file |
file_picker | |
signature |
signature pad | |
rating |
RatingBar |
🧩 Field Configuration Options #
type(String): Field type (see above)label(String): Field labelkey(String): Unique key for result maphint(String): Placeholder/hint textregex(String): Validation regexerror(String): Custom error messageinputType(String): 'text', 'email', 'number', etc.options(List): For dropdown/radiostep(int): Step number (for multi-step)min,max,divisions: For sliderminLength,maxLength,minLines,maxLines: For textminDate,maxDate: For daterequired(bool): Required fieldtitle(String): Step title (optional)
📋 Example Output #
On submit, you get a Map<String, dynamic> with all field values:
{
"name": "John Doe",
"signature": <Uint8List>,
// ...
}
📝 License #
MIT
Built with by Akshay