JsonWidgetRegistry constructor

JsonWidgetRegistry({
  1. Map<String, JsonWidgetBuilderContainer>? builders,
  2. bool overrideInternalBuilders = false,
  3. String? debugLabel,
  4. bool? disableValidation,
  5. Map<String, JsonWidgetFunction>? functions,
  6. bool overrideInternalFunctions = false,
  7. GlobalKey<NavigatorState>? navigatorKey,
  8. JsonWidgetRegistry? parent,
  9. List<ArgProcessor>? argProcessors,
  10. 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.

Implementation

JsonWidgetRegistry({
  Map<String, JsonWidgetBuilderContainer>? builders,
  bool overrideInternalBuilders = false,
  String? debugLabel,
  bool? disableValidation,
  Map<String, JsonWidgetFunction>? functions,
  bool overrideInternalFunctions = false,
  this.navigatorKey,
  JsonWidgetRegistry? parent,
  List<ArgProcessor>? argProcessors,
  Map<String, dynamic>? values,
})  : debugLabel = (parent != null ? '${parent.debugLabel}.' : '') +
          (debugLabel ?? 'child_${++childCount}'),
      disableValidation = !SchemaValidator.enabled,
      _parent = parent {
  _logger = Logger('REGISTRY ${this.debugLabel}');
  final cache = SchemaCache();
  cache.addSchema(
    JsonWidgetDataSchema.id,
    JsonWidgetDataSchema.schema,
  );
  if (!overrideInternalBuilders) {
    DefaultRegistrar.registerDefaults(registry: this);
  }
  _builders.addAll({if (builders != null) ...builders});
  _functions.addAll({
    if (!overrideInternalFunctions) ...JsonWidgetInternalFunctions.defaults(),
    if (functions != null) ...functions
  });
  _values.addAll(values ?? {});
  _parentDisposeStreamSubscription =
      parent?.disposeStream.listen((_) => dispose());
  _argProcessors = argProcessors ?? ArgProcessors.defaults;
  _parentValueStreamSubscription = parent?.valueStream
      .listen((event) => _valueStreamController?.add(event));
}