json_formkit 0.1.0 copy "json_formkit: ^0.1.0" to clipboard
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 support
  • email β€” email input with regex validation
  • phone β€” phone number field with validation (10–15 digits)
  • checkbox β€” toggle boolean field
  • dropdown β€” select from list
  • date β€” select a date

πŸ›‘οΈ Validation #

Each field supports:

  • required: true
  • Built-in validators (e.g. validateEmail, validatePhone)
  • Pass your own customValidator for full control

πŸ“„ License #

MIT


Made with ❀️ by the community.

0
likes
130
points
31
downloads

Publisher

unverified uploader

Weekly Downloads

A JSON-driven form builder package in Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_riverpod

More

Packages that depend on json_formkit