ZetaDateInput constructor

ZetaDateInput({
  1. Key? key,
  2. bool disabled = false,
  3. DateTime? initialValue,
  4. ValueChanged<DateTime?>? onChange,
  5. ZetaFormFieldRequirement? requirementLevel = ZetaFormFieldRequirement.none,
  6. FormFieldValidator<DateTime>? validator,
  7. ValueChanged<DateTime?>? onFieldSubmitted,
  8. FormFieldSetter<DateTime>? onSaved,
  9. AutovalidateMode? autovalidateMode,
  10. bool? rounded,
  11. String? label,
  12. String? hintText,
  13. String? errorText,
  14. ZetaWidgetSize size = ZetaWidgetSize.medium,
  15. String dateFormat = 'MM/dd/yyyy',
  16. DatePickerEntryMode? pickerInitialEntryMode,
  17. String? datePickerSemanticLabel,
  18. DateTime? minDate,
  19. DateTime? maxDate,
  20. String? clearSemanticLabel,
})

Creates a new ZetaDateInput

Implementation

ZetaDateInput({
  super.key,
  super.disabled = false,
  super.initialValue,
  super.onChange,
  super.requirementLevel = ZetaFormFieldRequirement.none,
  super.validator,
  super.onFieldSubmitted,
  super.onSaved,
  super.autovalidateMode,
  bool? rounded,
  this.label,
  this.hintText,
  this.errorText,
  this.size = ZetaWidgetSize.medium,
  this.dateFormat = 'MM/dd/yyyy',
  this.pickerInitialEntryMode,
  this.datePickerSemanticLabel,
  this.minDate,
  this.maxDate,
  this.clearSemanticLabel,
}) : super(
        builder: (field) {
          final _ZetaDateInputState state = field as _ZetaDateInputState;
          final colors = Zeta.of(field.context).colors;

          return InternalTextInput(
            label: label,
            hintText: hintText,
            errorText: field.errorText ?? errorText,
            size: size,
            placeholder: dateFormat,
            controller: state.controller,
            onSubmit: onFieldSubmitted != null ? (_) => onFieldSubmitted(field.value) : null,
            requirementLevel: requirementLevel,
            rounded: rounded,
            disabled: disabled,
            inputFormatters: [
              state._dateFormatter,
            ],
            suffix: Row(
              mainAxisAlignment: MainAxisAlignment.end,
              mainAxisSize: MainAxisSize.min,
              children: [
                if (state.controller.text.isNotEmpty)
                  InputIconButton(
                    icon: ZetaIcons.cancel,
                    onTap: state.clear,
                    disabled: disabled,
                    size: size,
                    color: colors.iconSubtle,
                    semanticLabel: clearSemanticLabel,
                  ),
                InputIconButton(
                  icon: ZetaIcons.calendar,
                  onTap: state.pickDate,
                  disabled: disabled,
                  size: size,
                  color: colors.iconDefault,
                  semanticLabel: datePickerSemanticLabel,
                ),
              ],
            ),
          );
        },
      );