json_schema_form_builder library

The public facade of json_schema_form_builder.

Every export below is a deliberate, supported API; extending this list is an API decision, not a convenience. Anything under src/ that is not exported here is internal with no stability guarantees: the package's own tests may import such files directly, consumers must not.

Classes

ArrayFieldHandler
The handler of array fields: builds ArrayFieldState (one child state per element, tuple and enum multi-select detection) and renders an ArrayField.
ArrayFieldState
The state of an array field: the element states, the schemas for appending new elements, and the enum multi-select detection.
BoolFieldHandler
The handler of boolean fields: builds BoolFieldState and renders a BoolField (checkbox).
BoolFieldState
The state of a boolean field.
CycleFieldHandler
Renders the fields collapsed by the registry's cycle guard (see CycleFieldState). Never selected by schema or value dispatch — the states are built directly by JsonHandlerRegistry.buildState — so its registration claims no types and is not pickable; it exists purely for the render-time state dispatch (handlerForField).
CycleFieldState
The state of a field collapsed by the registry's cycle guard: its schema is a $ref whose target was already expanded on the descent from the root (FieldResolveContext.expandedRefs) and it carries no value, so expanding it eagerly would recurse forever (node -> next -> node -> …).
DoubleFieldHandler
The handler of number fields: builds DoubleFieldState and renders a DoubleField.
DoubleFieldState
The state of a number field.
EnumFieldHandler
The handler of select-like fields: builds EnumFieldState and renders an EnumField. Selected by the registry for every schema with enum (or pinned alternatives), regardless of the value type.
EnumFieldState
The state of a select-like field (enum, or alternatives with pinned values).
EnumOption
A fixed option of a select-like schema: the admitted value and the label it is displayed with.
FieldAnnotations
The presentation annotations of a field, extracted from its resolved schema (description, examples, required, default, readOnly). Grouped into one object to reduce the number of properties in copyWith and the number of properties passed down the chain.
FieldBuildRequest
Parameter object for the state building pipeline (JsonHandlerRegistry.buildState -> JsonFieldStateBuilder.buildState).
FieldDisplayContext
FieldResolveContext plus presentation state: how deep inside the currently opened dialog the field is, whether its title row is shown, and the whole-form state for cross-field decisions. Widgets derive children with child, open a fresh dialog scope with resetDisplay and suppress the title row with withoutHeader.
FieldResolveContext
The domain-side context of state building: where the field lives inside the JSON document (grown top-down by child as the pipeline descends into object properties and array items) plus the root schema, so document-rooted $refs (#/definitions/...) and the best-matching-alternative search can see the whole document.
FormTheme
Applies FormThemeData to the descendant form widgets, analogous to Material component theme widgets (CardTheme, ListTileTheme):
FormThemeData
Visual configuration for form_foundation widgets.
IntFieldHandler
The handler of integer fields: builds IntFieldState and renders an IntField.
IntFieldState
The state of an integer field.
JsonEditor
A plain-props JSON text editor: syntax highlighting, pretty-printing, parse-on-change and a careful sync with an externally changing value.
JsonFieldHandler<FS extends JsonFieldState<Schema>>
A field handler: the domain half (JsonFieldStateBuilder) plus the presentation half (JsonFieldRenderer) in one class. The registry's state-building pipeline depends only on the builder interface; UI code depends only on the renderer one. The Variant switcher composition lives in the widgets layer (widgets/field_with_variants.dart), so this file stays free of widget imports.
JsonFieldRenderer<FS extends JsonFieldState<Schema>>
The presentation half of a field handler: renders a state built by the JsonFieldStateBuilder counterpart. UI consumers (the form tree, the Variant switcher, the entry dialog's "Value type" picker) depend on this contract; the state-building pipeline never does.
JsonFieldState<SC extends Schema>
The immutable state of one field of the form: the value, the resolved schema fragment it was built from, the validation result, and the anyOf/oneOf variant machinery. Concrete subclasses (StringFieldState, ObjectFieldState, ...) add their type-specific parts.
JsonFieldStateBuilder<FS extends JsonFieldState<Schema>>
The domain half of a field handler: everything the state-building pipeline (JsonHandlerRegistry.buildState and friends) needs, and nothing the UI needs. Deliberately free of Flutter types (no Widget/BuildContext), so the Json -> State -> Json pipeline can be exercised and faked without widgets.
JsonFormLocalizations
Callers can lookup localized strings with an instance of JsonFormLocalizations returned by JsonFormLocalizations.of(context).
JsonFormLocalizationsDelegate
Registers a JsonFormLocalizations (sub)class per locale: the way a host plugs in its own language (see jsonFormLocalizationsOf for an example).
JsonFormLocalizationsEn
The translations for English (en).
JsonFormLocalizationsPl
The translations for Polish (pl).
JsonFormLocalizationsRu
The translations for Russian (ru).
JsonHandlerRegistration
One entry of a type-based registry configuration (see TypeBasedJsonHandlerRegistry.fromRegistrations): the handler instance plus its wiring — the roles this registration assigns to the handler.
JsonHandlerRegistry
Base registry owning the state building pipeline and validation context creation. Subclasses define only the handler selection policy via stateBuilderFor, stateBuilderForValue and handlersForSchema.
JsonHighlightingController
A TextEditingController that renders its text through highlightJson; the light/dark palette is picked per build from the ambient theme.
JsonListFieldEntry
One element of an ArrayFieldState: the element's state plus whether it sits beyond the positional (tuple) schemas.
JsonSchemaForm
The turnkey form: renders an editor tree generated from schema, starting at initialValue.
JsonSchemaFormState
The state of a JsonSchemaForm; reached with a GlobalKey<JsonSchemaFormState> to trigger validate, the same pattern as Flutter's Form/FormState.
LatestRequestGuard
Guard for the "latest request wins" async pattern.
NullFieldHandler
The handler of type: "null" fields: builds NullFieldState and renders a NullField.
NullFieldState
The state of a type: "null" field.
ObjectFieldHandler
The handler of object fields: builds ObjectFieldState (one child state per rendered property) and renders an ObjectField.
ObjectFieldState
The state of an object field: one child state per rendered property plus the pattern-property schemas for naming new entries.
PickedFileData
A file picked by a DataUrlFilePicker.
PresenceValue<T>
A presence-aware value container: distinguishes "the key is absent from the document" (PresenceValue.absent) from "the key is present with the value null" (PresenceValue(null)) — a distinction plain nullable types cannot express and JSON editing depends on (removing a key vs writing an explicit null are different edits).
RawField
The form-field face of the raw JSON editor: adapts a RawFieldState to the plain-props JsonEditor (which owns highlighting, parsing and value sync) and applies the form field padding.
RawFieldHandler
The handler of raw JSON fields: builds RawFieldState and renders a RawField (free-form JSON text editing for any value).
RawFieldState
The state of a raw JSON field: any value edited as JSON text.
SchemaMerger
Merges JSON Schema fragments (allOf branches, a $ref target with its local siblings) key by key, delegating each keyword to the first SchemaKeyMergeStrategy that accepts it.
SchemaWithContext
A schema paired with the ValidationContext able to resolve its $refs (the context's SchemaRegistry holds the root document at the source URI).
StringFieldHandler
The handler of string fields: builds StringFieldState and renders the editor matching the schema's format — date, time, date-time and data-url get dedicated pickers, everything else a plain text field.
StringFieldState
The state of a string field; format selects the editor (date, time, date-time, data-url or plain text).
TypeBasedJsonHandlerRegistry
Selection policy: enum keyword -> enumFieldHandler, otherwise the JSON Schema types claimed by the registrations (JsonHandlerRegistration.schemaTypes), with a value-type based fallback when the schema does not constrain the type.
UnknownFieldHandler
The fallback handler for fields no registered handler accepts: builds UnknownFieldState and renders the read-only UnknownField. Wired into the registry as unknownFieldHandler, not registered for any type.
UnknownFieldState
The state of a field the registry could not dispatch: no registered handler accepted the schema or the value.

Enums

ObjectFieldDisplayMode
Controls which fields are visible in the object editor.
SchemaValidationMode
How the library validates values while they are edited (the entry edit dialog, the array item add dialog, JsonHandlerRegistry.validateValue).
ValidationErrorType
Enum representing the types of validation failures when checking data against a schema.

Extension Types

Schema
A JSON Schema object defining any kind of property.
ValidationError
A validation error with detailed information about the location of the error.

Extensions

FieldWithVariants on JsonFieldHandler<FS>
Presentation-side composition of the anyOf/oneOf alternatives switcher.
SubmittableJsonFieldState on JsonFieldState<Schema>
The submission gate: whether a state passes under a SchemaValidationMode.
ValidatorRejectedSchemaFlag on ValidationError
Detection of the sentinel error produced by validatorRejectedSchemaErrors.

Constants

defaultMinInlineWidth → const double
Default minimal width (logical px) at which inline object/array editors are considered usable; below it they collapse into a compact editor (a button that opens the edit dialog).

Functions

dartTypeOfValue(dynamic value) → Type
The canonical Dart type of a decoded JSON value: the vocabulary of JsonHandlerRegistration.valueTypes and of the canEditValue implementations. Both sides of the value-based handler lookup must use this function rather than runtimeType (e.g. any Map normalizes to Map<String, dynamic>, any List to List<dynamic>).
highlightJson(String text, {required Brightness brightness, TextStyle? style}) → TextSpan
Highlights text as JSON into a TextSpan tree.
isNullableSchema(Schema? schema) → bool
Whether schema explicitly admits null via a union type ("type": [..., "null"]).
jsonFormLocalizationsOf(BuildContext context) → JsonFormLocalizations
The UI strings of json_schema_form_builder widgets.
jsonTypeOfValue(dynamic value) → JsonType?
JSON Schema type of a decoded JSON value (e.g. used to narrow a schema's accepted types by the current value).
lookupJsonFormLocalizations(Locale locale) → JsonFormLocalizations
schemaEnumOptions(Schema? schema) → List<EnumOption>?
The full set of values a select-like schema admits, paired with display labels (react-jsonschema-form's optionsList): either a plain enum, or anyOf/oneOf where every alternative pins its value (schemaPinnedValue) and the label comes from the alternative's title. Null when the schema is not select-like.
schemaHasConst(Schema? schema) → bool
Whether schema pins the value with the const keyword. containsKey (not a null check) so that const: null is honored too.
schemaPinnedValue(Schema? schema) → PresenceValue<Object?>
The value schema admits as the only one: const, a single-element enum (react-jsonschema-form's isConstant), or the null type — its value domain is the single value null, so type: "null" pins exactly like const: null (rjsf reaches the same result differently: its null field renders no input and writes null on mount). Absent when the schema does not pin the value. Used where selecting an anyOf/oneOf alternative must write the value it stands for.
schemaSeedValue(Schema? schema, {Schema? rootSchema}) → PresenceValue<Object?>
The value a schema prescribes for a newly created field: const wins, then default, then -- for objects -- the property defaults collected recursively. An object's own default and its property defaults are merged per key, the explicit default winning and the property defaults filling the keys it does not cover; the merge is deep, following react-jsonschema-form's computeDefaults (a default handed down by the parent takes precedence over the schema's own default on every level). Absent when the schema prescribes nothing.
standardJsonHandlerRegistry({SchemaMerger? schemaMerger, ObjectFieldDisplayMode displayMode = ObjectFieldDisplayMode.all, bool arrayInline = false, bool objectInline = true, DataUrlFilePicker? filePicker, JsonFieldHandlerBuilder? unknownFieldHandler, Map<Type, JsonHandlerRegistrationBuilder> overrides = const {}, SchemaValidationMode validationMode = SchemaValidationMode.strict}) → JsonHandlerRegistry
The standard registry: every built-in handler wired in with its default registration (see JsonHandlerRegistration), the lazy handler ↔ registry cycle closed internally. This file is the package's composition root and therefore sits at the src/ root: it assembles the machinery that lives in models/ and the handlers that live in handlers/. Consumers configure common knobs via parameters and replace whole registrations via overrides instead of assembling ~10 constructors with registryGetter: () => registry by hand.
switchRepresentationValue({required Schema? targetSchema, required PresenceValue currentValue, bool admits(Object? value)?, PresenceValue? emptySeed, Schema? rootSchema}) → PresenceValue
The single write policy for switching a value's representation — an anyOf/oneOf branch in the Variant switcher or a value type in the entry dialog's picker. Both UIs must route through this function so the written value does not depend on where the user initiated the switch.
typesAcceptedBy(Schema schema) → List<JsonType>
JSON Schema types accepted by schema: the explicit type keyword when present, otherwise inferred from characteristic keywords and enum/const samples. An empty list means the schema does not constrain the type.
validateDataBySchema(Schema? schema, Object? data) → Future<List<ValidationError>?>
Standalone validation of data against schema that never throws: a schema the validator cannot process surfaces as a single visible custom error (validatorRejectedSchemaErrors) instead of crashing the caller (the same policy as JsonHandlerRegistry.validateValue). The validation context comes from buildStandaloneValidationContext: schema is its own root document, and the $schema keyword resolves against the pre-registered meta-schema stubs instead of the network (a plain schema.validate fetches the meta schema, which fails offline and on the web: "Failed to resolve meta schema"). Null when schema is null (nothing to validate against).
valueAsString(PresenceValue value, {String notPresented = ''}) → String
Display form of a field value regardless of its type: notPresented for an absent value, the literal string null for JSON null, toString otherwise. Used where a widget must show SOMETHING for a value it cannot edit (e.g. the checkbox displayValue for a non-bool).

Typedefs

DataUrlFilePicker = Future<PickedFileData?> Function()
Returns the picked file, or null when the user cancelled the dialog.
JsonFieldHandlerBuilder = JsonFieldHandler<JsonFieldState<Schema>> Function(JsonHandlerRegistry registryGetter())
Builds one handler for the standard registry. Receives the registry getter (the registry does not exist yet while its handlers are being constructed), so custom handlers close the handler ↔ registry cycle the same way the built-in ones do.
JsonHandlerRegistrationBuilder = JsonHandlerRegistration Function(JsonHandlerRegistry registryGetter())
Builds a JsonHandlerRegistration given the getter that closes the lazy handler ↔ registry cycle (the registry does not exist yet while its handlers are being constructed).