json_formkit 0.1.0
json_formkit: ^0.1.0 copied to clipboard
A JSON-driven form builder package in Flutter.
π¦ json_formkit #
A dynamic, themeable, and developer-friendly Flutter forms plugin powered by JSON configuration. Supports built-in validators, custom form fields, and full theming control.
β¨ Features #
- Build complete forms using simple JSON config
- Reusable form fields with built-in validators (e.g. phone, email, etc.)
- Custom validator support per field
- Form submission returns data as JSON map
- Fully customizable form theming
- Light and dark mode support
π¦ Installation #
Add to your pubspec.yaml:
dependencies:
json_formkit: <latest>
π Usage #
final formJson = [
{
"type": "text",
"name": "full_name",
"label": "Full Name",
"required": true,
},
{
"type": "phone",
"name": "contact_number",
"label": "Phone Number",
"required": true,
},
{
"type": "checkbox",
"name": "accept_terms",
"label": "Accept Terms",
"required": true,
}
];
JsonForm(
formConfig: formJson,
onSubmit: (formData) {
print("Form submitted: \$formData");
},
);
π¨ Custom Themes #
You can pass a FormTheme object to override styling for each field type.
JsonForm(
formConfig: formJson,
theme: FormTheme(
inputDecoration: InputDecoration(
border: OutlineInputBorder(),
filled: true,
fillColor: Colors.grey.shade200,
),
labelStyle: TextStyle(
color: Colors.deepPurple,
fontWeight: FontWeight.bold,
),
errorStyle: TextStyle(
color: Colors.redAccent,
),
checkboxActiveColor: Colors.deepPurple,
dropdownStyle: TextStyle(color: Colors.deepPurple),
datePickerTextStyle: TextStyle(color: Colors.deepPurple),
),
);
If no theme is passed, it defaults to light or dark theme based on context.
β Built-in Field Types #
textβ normal input field with word limit supportemailβ email input with regex validationphoneβ phone number field with validation (10β15 digits)checkboxβ toggle boolean fielddropdownβ select from listdateβ select a date
π‘οΈ Validation #
Each field supports:
required: true- Built-in validators (e.g.
validateEmail,validatePhone) - Pass your own
customValidatorfor full control
π License #
MIT
Made with β€οΈ by the community.