ZetaSelectInput<T> constructor

ZetaSelectInput<T>({
  1. Key? key,
  2. bool? rounded,
  3. FormFieldValidator<T>? validator,
  4. ValueChanged<T?>? onFieldSubmitted,
  5. AutovalidateMode? autovalidateMode,
  6. FormFieldSetter<T>? onSaved,
  7. bool disabled = false,
  8. T? initialValue,
  9. ValueChanged<T?>? onChange,
  10. ZetaFormFieldRequirement? requirementLevel,
  11. required List<ZetaDropdownItem<T>> items,
  12. ValueSetter<String>? onTextChanged,
  13. ZetaWidgetSize size = ZetaWidgetSize.medium,
  14. String? label,
  15. String? hintText,
  16. Widget? prefix,
  17. String? placeholder,
  18. String? errorText,
  19. String? dropdownSemantics,
})

Constructor of ZetaSelectInput

Implementation

ZetaSelectInput({
  super.key,
  bool? rounded,
  super.validator,
  super.onFieldSubmitted,
  super.autovalidateMode,
  super.onSaved,
  super.disabled = false,
  super.initialValue,
  super.onChange,
  super.requirementLevel,
  required this.items,
  this.onTextChanged,
  this.size = ZetaWidgetSize.medium,
  this.label,
  this.hintText,
  this.prefix,
  this.placeholder,
  this.errorText,
  this.dropdownSemantics,
}) : super(
        builder: (field) {
          final _ZetaSelectInputState<T> state = field as _ZetaSelectInputState<T>;
          final colors = Zeta.of(field.context).colors;

          return ZetaRoundedScope(
            rounded: rounded ?? field.context.rounded,
            child: ZetaDropdown<T>(
              disableButtonSemantics: true,
              items: state.currentItems,
              onChange: !disabled ? state.setItem : null,
              key: state.dropdownKey,
              value: state._selectedItem?.value,
              offset: Offset(0, Zeta.of(field.context).spacing.xl * -1),
              onDismissed: state.onDropdownDismissed,
              builder: (context, _, controller) {
                return InternalTextInput(
                  size: size,
                  requirementLevel: requirementLevel,
                  disabled: disabled,
                  controller: state.inputController,
                  focusNode: state.inputFocusNode,
                  prefix: state._selectedItem?.icon ?? prefix,
                  label: label,
                  onSubmit: (_) {
                    state.onInputSubmitted(controller);
                    onFieldSubmitted?.call(state._selectedItem?.value);
                  },
                  errorText: field.errorText ?? errorText,
                  placeholder: placeholder,
                  hintText: hintText,
                  onChange: (val) => state.onInputChanged(controller),
                  suffix: InputIconButton(
                    semanticLabel: dropdownSemantics,
                    icon: controller.isOpen ? ZetaIcons.expand_less : ZetaIcons.expand_more,
                    disabled: disabled,
                    size: size,
                    color: colors.iconSubtle,
                    onTap: () => state.onIconTapped(controller),
                  ),
                );
              },
            ),
          );
        },
      );