ArrayFieldState class

The state of an array field: the element states, the schemas for appending new elements, and the enum multi-select detection.

Inheritance

Constructors

ArrayFieldState({required PresenceValue value, required List<JsonListFieldEntry> children, required List<JsonFieldState<Schema>>? variants, required Schema? rootSchema, Set<int> matchedVariantIndices = const {}, String? title, FieldAnnotations? fieldAnnotations, ListSchema? schema, List<Schema> positionalItemSchemasForNew = const [], Schema? additionalItemsSchemaForNew, bool uniqueItems = false, List<ValidationError>? errors})
Creates an array field state.
const

Properties

additionalItemsSchemaForNew → Schema?
Resolved schema for elements beyond the positional ones; null when the tuple is closed or items is unconstrained.
final
children → List<JsonListFieldEntry>
The element states, in document order.
final
childrenHasErrors → bool
Whether any element failed validation (surfaced on the collapsed representation, where element errors are invisible).
no setter
curVariant → JsonFieldState<Schema>?
The state of the single matched variant, or null when nothing matched or the match is unresolvable.
no setterinherited
enumOptions → List<EnumOption>?
Options of the enum multi-select; null when the items schema is not select-like (schemaEnumOptions).
no setter
errors → List<ValidationError>?
Validation result of this state.
finalinherited
errorsAsString → String?
The validation messages joined for display, or null when there are none.
no setterinherited
fieldAnnotations → FieldAnnotations?
Presentation annotations from the resolved schema (description, examples, required, default, readOnly).
finalinherited
hasErrors → bool
Validated and failed.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hasValue → bool
Whether the document carries a value for this field (an explicit null counts as a value).
no setterinherited
isEnum → bool
Whether the array renders as an enum multi-select (EnumArrayField): unique items whose items schema is select-like -- a plain enum or anyOf/oneOf of pinned alternatives. Mirrors react-jsonschema-form's isMultiSelect.
no setter
isValid → bool
Validated and clean. False both for a failed validation and for a state that was never validated.
no setterinherited
isValidated → bool
Whether validation has run for this state (see errors).
no setterinherited
itemsSchemaForEnum → Schema?
The items schema the multi-select works with: the one resolved against the validation context when available (additionalItemsSchemaForNew), so an items given as a $ref is seen through; the raw items schema otherwise. Null for a tuple (positional prefixItems, or the draft-07 form of a List-valued items).
no setter
matchedVariantIndices → Set<int>
The anyOf/oneOf alternatives matched against the value.
finalinherited
positionalItemSchemasForNew → List<Schema>
Resolved positional (tuple) schemas: the next new element takes the first still-unfilled one.
final
rootSchema → Schema?
The whole schema document, needed to resolve document-local $refs reachable from schema.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
schema → ListSchema?
Kept here and used only for determining the best schema via the closestVariantIndices function. If not for it, the schema would not be needed here in most cases (Map, List). Try to avoid using this schema, preferring the State properties instead.
finalinherited
title → String?
The field label (the schema's title or a derived fallback).
finalinherited
uniqueItems → bool
The schema's uniqueItems; with a select-like items schema it turns the editor into an enum multi-select (see isEnum).
final
value → PresenceValue
The field's value slice of the document; absent when the document does not carry this field.
finalinherited
valueOrNull → dynamic
The value, or null when it is absent — indistinguishable from an explicit null; use value where the distinction matters.
no setterinherited
variants → List<JsonFieldState<Schema>>?
One pre-built state per anyOf/oneOf alternative (or per synthesized type branch); null when the schema offers no alternatives. See the staleness contract on copyWith.
finalinherited

Methods

applyErrors(List<ValidationError> errors) → ArrayFieldState
Distributes errors by path: element errors go into the matching child states, the rest (including unassignable paths) stay on the array itself.
override
applyVariantUpdate(int index, JsonFieldState<Schema> variantState, PresenceValue? emptyValue) → JsonFieldState<ListSchema>
Returns this unchanged if index is out of the bounds of variants (the assert fires only in debug). Public callers must check the bounds themselves beforehand and report the violation via a platform-appropriate mechanism (see ObjectField._onVariantChanged) — this method does not guarantee error visibility in production.
inherited
clear() → JsonFieldState<ListSchema>
A copy with the value removed from the document (absent, not null).
inherited
copyWith({Set<int>? matchedVariantIndices, PresenceValue? value, List<JsonFieldState<Schema>>? variants, List<JsonListFieldEntry>? children}) → ArrayFieldState
See the staleness contract on JsonFieldState.copyWith; children follows the same rule (a build-time snapshot, not refreshed by point writes).
override
markUnvalidated() → JsonFieldState<ListSchema>
A copy marked as not validated (errors = null, see the contract there); this when the state has not been validated already.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rebuild({required PresenceValue value, required Set<int> matchedVariantIndices, required List<JsonFieldState<Schema>>? variants, required List<ValidationError>? errors}) → ArrayFieldState
The low-level copy constructor — the ONE method a subclass implements (a plain constructor call passing the parameters through and carrying its own extra fields over). Every parameter is required and written verbatim; there is no null-means-keep convention here — that lives in copyWith, and the errors semantics live in applyErrors / markUnvalidated, all implemented on top of this.
override
resolveVariantUpdate(JsonFieldState<Schema> variantState, List<JsonFieldState<Schema>> actualVariants, PresenceValue? emptyValue) → JsonFieldState<ListSchema>
Applies an edit made inside a variant branch: adopts the branch state's value (falling back to emptyValue, then to the current value, when the branch carries none) and stores the updated actualVariants. Containers override this to merge instead of replace (see ObjectFieldState).
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited