renderProperty method

  1. @override
Iterable<Widget> renderProperty(
  1. BuildContext context,
  2. IMetaFormContext metaForm,
  3. HandledPaths paths,
  4. SunnyFormFieldState<MKey?> state, {
  5. Key? key,
})
override

Renders a widget (or null) for a provided HandledPaths (see acceptProperties)

Implementation

@override
Iterable<Widget> renderProperty(
    BuildContext context, IMetaFormContext metaForm, HandledPaths paths, SunnyFormFieldState<MKey?> state,
    {Key? key}) {
  final prop = paths.property as IRefProperty;
  final theRef = prop.theRef;
  final _mfProp = metaForm.prop(paths.property!);
  KeyedOptionsHandler<MKey?, T?> handler = context.optionsService.getKeyedHandler(theRef, metaContext: _mfProp);

  final viewHandler = context.typeaheadService.getTypeaheadRenderer<MKey, T>(theRef);

  final fullPath = paths.fullPath<MKey>();

  return [
    OptionSelectorControl<MKey?, T?>(
      key: Key("field-$fullPath"),
      handler: handler,
      focusNode: state.focusNode,
      isRequired: prop.isRequired == true,
//      noOptionsLabel: widget.noOptionsLabel,
//        autofocus: widget.autofocus ?? false,
      onChange: (value, source) {
        state.updateValue(value?.key, source);
      },
      expected: (option) => option?.key,
      onError: (error) => state.error = error,
      initialKeyValue: state.value,
      viewHandler: viewHandler,
    )
  ];
}