CustomizableMultiselectField constructor

CustomizableMultiselectField({
  1. Key? key,
  2. FormFieldSetter<List<List>>? onSaved,
  3. FormFieldValidator<List<List>>? validator,
  4. AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  5. ValueChanged<List<List>>? onChanged,
  6. InputDecoration? decoration,
  7. required List<DataSource> dataSourceList,
  8. CustomizableMultiselectDialogOptions customizableMultiselectDialogOptions = const CustomizableMultiselectDialogOptions(),
  9. CustomizableMultiselectWidgetOptions customizableMultiselectWidgetOptions = const CustomizableMultiselectWidgetOptions(),
})

Implementation

CustomizableMultiselectField({
  Key? key,
  FormFieldSetter<List<List<dynamic>>>? onSaved,
  FormFieldValidator<List<List<dynamic>>>? validator,
  AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
  ValueChanged<List<List<dynamic>>>? onChanged,
  InputDecoration? decoration,
  required this.dataSourceList,
  this.customizableMultiselectDialogOptions =
      const CustomizableMultiselectDialogOptions(),
  this.customizableMultiselectWidgetOptions =
      const CustomizableMultiselectWidgetOptions(),
}) : super(
        key: key,
        onSaved: onSaved,
        validator: validator,
        initialValue: dataSourceList
            .map((DataSource dataSource) => dataSource.valueList)
            .toList(),
        autovalidateMode: autovalidateMode,
        enabled: customizableMultiselectWidgetOptions.enable,
        builder: (FormFieldState<List<List<dynamic>>> field) {
          final InputDecoration effectiveDecoration = (decoration ??
                  const InputDecoration())
              .applyDefaults(Theme.of(field.context).inputDecorationTheme);
          void onChangedHandler(List<List<dynamic>> value) {
            if (onChanged != null) {
              onChanged(value);
            }
            field.didChange(value);
          }

          return CustomizableMultiselectWidget(
            dataSourceList: dataSourceList,
            onChanged: onChangedHandler,
            customizableMultiselectDialogOptions:
                customizableMultiselectDialogOptions,
            customizableMultiselectWidgetOptions:
                customizableMultiselectWidgetOptions,
            decoration:
                effectiveDecoration.copyWith(errorText: field.errorText),
            value: field.value,
          );
        },
      );