JsonWidgetRegistry class

Registry for both the library provided as well as custom form builders that the application may provide.

This provides a default instance that can be used for an entire application. Applications that need a custom registry for specific use cases can instead create a new one to pass to the JsonWidgetData.

Applications wishing to provide their own widget builders must register them via the registerCustomBuilder function before they are needed by the form. This should typically happen within the main function of the application.

By default, JSON schema validation is enabled in DEBUG builds. It is always disabled in RELEASE builds. To disable validation even in DEBUG builds, set disableValidation to true.

Constructors

JsonWidgetRegistry({Map<String, JsonWidgetBuilderContainer>? builders, bool overrideInternalBuilders = false, String? debugLabel, bool? disableValidation, Map<String, JsonWidgetFunction>? functions, bool overrideInternalFunctions = false, GlobalKey<NavigatorState>? navigatorKey, JsonWidgetRegistry? parent, List<ArgProcessor>? argProcessors, Map<String, dynamic>? values})
Constructs a one-off registry. This accepts an optional group of custom widget builders, custom widget functions, and widget values. It allows to extend the default syntax with custom one by passing argProcessors.

Properties

debugLabel String
final
disableValidation bool
final
disposeStream Stream<void>
Returns the Stream that an element can listen to in order to be notified when the registry is disposed. Typically this should only be used by child registries listening to notifications from their parent registries.
no setter
functions Map<String, JsonWidgetFunction>
Returns an unmodifiable reference to the internal set of functions.
no setter
hashCode int
The hash code for this object.
no setterinherited
A navigator key that is required in order to use the fun_key_navigate_named and fun_key_navigate_pop functions. This holds the navigator state that will be used to push the named route to the stack.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
values Map<String, dynamic>
Returns an unmodifiable reference to the internal set of values.
no setter
valueStream Stream<WidgetValueChanged>
Returns the Stream that an element can listen to in order to be notified when a value has changed.
no setter

Methods

clearValues() → void
Removes all variable values from the registry
copyWith({Map<String, JsonWidgetBuilderContainer>? builders, String? debugLabel, bool? disableValidation, Map<String, JsonWidgetFunction>? functions, GlobalKey<NavigatorState>? navigatorKey, List<ArgProcessor>? argProcessors, JsonWidgetRegistry? parent, Map<String, dynamic>? values}) JsonWidgetRegistry
dispose() → void
Disposes the registry.
execute(String? key, Iterable? args) → dynamic
Executes the dynamic function named key. This will first check for a custom dynamic function using the key, and if none is found, this will then check the internal functions. If no function can be found in either collection, this will throw an Exception.
getFunction(String? functionName) JsonWidgetFunction?
Returns the function with the given functionName. If a function with named functionName cannot be found, this will return null.
getValue(String? key) → dynamic
Returns the variable value for the given key.This will first check for a custom dynamic value using the key, and if none is found, this will then check the internal values. If a variable with named key cannot be found, this will return null.
getWidgetBuilder(String type) JsonWidgetBuilderBuilder
Returns the builder for the requested type. This will first search the registered custom builders, then if no builder is found, this will then search the library provided builders.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
processArgs(dynamic args, Set<String>? jsonWidgetListenVariables) ProcessedArg
Process JsonWidgetData args by using _argProcessors. Default processors are definied in ArgProcessors.defaults. Passing jsonWidgetListenVariables is skipping the step of calculating these variables during processing. Processing is mostly about executing pipeline of processors and finding first supported one. In case of not finding any processor RawArgProcessoris used instead.
registerArgProcessors(List<ArgProcessor> argProcessors) → void
Registers custom arg processors. It allows to extend the default syntax with custom one.
registerCustomBuilder(String type, JsonWidgetBuilderContainer container) → void
Registers the widget type with the registry to that type can be used in custom forms. Types registered by the application take precidence over built in registered builders. This allows an application the ability to provide custom widgets even for built in form types.
registerCustomBuilders(Map<String, JsonWidgetBuilderContainer> containers) → void
Registers the custom builders. This is a convenience method that calls registerCustomBuilder for each entry in containers.
registerFunction(String key, JsonWidgetFunction fun) → void
Registers the key as function name with the registry to be used in function bindings. Functions registered by the application take precidence over built in registered functions. This allows the application the ability to provide custom functions even for built in key's.
registerFunctions(Map<String, JsonWidgetFunction> functions) → void
Registers the function bindings. This is a convenience method that calls registerFunction for each entry in functions.
removeValue(String key, {String? originator}) → dynamic
Removes the key from the registry.
setValue(String key, dynamic value, {String? originator}) → void
Sets the value for the key on the registry. If the value is null, this redirects to removeValue.
toString() String
A string representation of this object.
override
unregisterCustomBuilder(String type) JsonWidgetBuilderContainer?
Removes a registered type from the custom registry and returns the associated builder, if one exists. If the type is not registered then this will null.
unregisterFunction(String key) JsonWidgetFunction?
validateBuilderSchema({required String type, required dynamic value, bool validate = true}) bool
Validates the builder against it's value. This will only perform a validation if a schema id is associated with builder.

Operators

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

Static Properties

childCount int
getter/setter pair
instance JsonWidgetRegistry
final