json_driven_dynamic_form library
A production-ready Flutter package that generates fully dynamic forms from JSON schemas.
Quick start
final controller = DynamicFormController();
DynamicForm(
json: {
'title': 'User Registration',
'fields': [
{'type': 'text', 'key': 'name', 'label': 'Full Name', 'required': true},
{'type': 'email', 'key': 'email', 'required': true},
{'type': 'number', 'key': 'age'},
],
},
controller: controller,
onSubmit: (values) => print(values),
);
Classes
- ConditionEvaluator
- Evaluates FieldCondition / FieldConditionGroup against form values.
- DynamicForm
- Renders a complete form from a JSON schema (or FormSchema).
- DynamicFormController
- Controls values, validation, and events for a FormSchema-driven form.
- DynamicFormLocalizations
- Localizable copy for form chrome and built-in validation messages.
- DynamicFormLocalizationsProvider
- Inherited localizations for form widgets.
- DynamicFormPluginRegistry
- Registry for custom field renderers and media services (Phase 5 plugin API).
- DynamicFormPlugins
- Inherited access to the plugin registry.
- DynamicFormState
- Snapshot of form state exposed to listeners.
- DynamicFormTheme
- Theme customization for DynamicForm and its fields.
- DynamicFormThemeProvider
- Inherited theme for descendant form widgets.
- FieldCondition
- A single condition that can drive visibility / enabled state.
- FieldConditionGroup
- Combinable set of conditions with AND / OR logic.
- FieldOption
- A selectable option for radio, dropdown, or chips fields.
- FieldRenderContext
- Context passed to custom field renderers.
- FormCameraCapture
- Captures images from the camera.
- FormFieldSchema
- Immutable schema describing a single form field.
- FormFilePicker
- Picks arbitrary files.
- FormImagePicker
- Picks images from gallery.
- FormLocationProvider
- Provides the device's current location.
- FormMediaServices
- Bundles injectable media services for Phase 4 fields.
- FormSchema
- Immutable top-level form schema parsed from JSON.
- FormSchemaParser
- Parses form schemas from JSON maps or JSON strings.
- FormSchemaValidator
- Validates form schema JSON before rendering, collecting all issues with JSON paths so the UI can show where the schema is wrong.
- LocationValue
- Represents a geographic location value.
- MediaFileValue
- Represents a picked file or image for media fields.
- MockFormCameraCapture
- Mock camera capture.
- MockFormFilePicker
- Mock file picker.
- MockFormImagePicker
- Demo / test implementations that return deterministic fake media values.
- MockFormLocationProvider
- Mock location provider (San Francisco).
- SchemaErrorView
- Full-screen / inline UI shown when schema JSON validation fails.
- SchemaValidationIssue
- A single schema validation finding with a JSON path.
- SchemaValidationResult
- Result of validating a form schema JSON document.
- ValidationContext
- Context passed to field validators.
- ValidationRule
- A single validation rule declared in JSON or constructed in code.
- Validators
- Built-in validators and a small engine that evaluates field rules.
Enums
- ConditionOperator
- Comparison operators used by conditions and compare validators.
- FieldType
- Supported form field types.
- SchemaIssueSeverity
- Severity of a schema validation issue.
- ValidatorType
- Built-in validator kinds that can be declared in JSON.
Functions
-
mockMediaServices(
) → FormMediaServices - Convenience bundle of all mock media services.
Typedefs
-
AsyncFieldValidator
= Future<
String?> Function(dynamic value, ValidationContext context) - Signature for an asynchronous field validator (Phase 4+).
- FieldRenderer = Widget Function(FieldRenderContext ctx)
- Builds a widget for a field schema.
- FieldValidator = String? Function(dynamic value, ValidationContext context)
- Signature for a synchronous field validator.
-
ServerFieldValidator
= Future<
String?> Function(dynamic value, ValidationContext context, ValidationRule rule) - Signature for a server validator that receives optional URL metadata.
Exceptions / Errors
- DynamicFormException
- Base exception for the json_driven_dynamic_form package.
- FormSchemaParseException
- Thrown when JSON schema parsing fails.
- ValidatorConfigException
- Thrown when validation configuration is invalid.