DateTimeField constructor

DateTimeField({
  1. required DateFormat format,
  2. required Future<DateTime?> onShowPicker(
    1. BuildContext context,
    2. DateTime? currentValue
    ),
  3. Key? key,
  4. FormFieldSetter<DateTime>? onSaved,
  5. FormFieldValidator<DateTime>? validator,
  6. DateTime? initialValue,
  7. AutovalidateMode? autovalidateMode,
  8. bool enabled = true,
  9. Icon? resetIcon = const Icon(Icons.close),
  10. void onChanged(
    1. DateTime? value
    )?,
  11. TextEditingController? controller,
  12. FocusNode? focusNode,
  13. InputDecoration? decoration = const InputDecoration(),
  14. TextInputType? keyboardType,
  15. TextCapitalization textCapitalization = TextCapitalization.none,
  16. TextInputAction? textInputAction,
  17. TextStyle? style,
  18. StrutStyle? strutStyle,
  19. TextDirection? textDirection,
  20. TextAlign textAlign = TextAlign.start,
  21. bool autofocus = false,
  22. bool readOnly = true,
  23. bool? showCursor,
  24. bool obscureText = false,
  25. bool autocorrect = true,
  26. MaxLengthEnforcement maxLengthEnforcement = MaxLengthEnforcement.enforced,
  27. int maxLines = 1,
  28. int? minLines,
  29. bool expands = false,
  30. int? maxLength,
  31. VoidCallback? onEditingComplete,
  32. ValueChanged<DateTime?>? onFieldSubmitted,
  33. List<TextInputFormatter>? inputFormatters,
  34. double cursorWidth = 2.0,
  35. Radius? cursorRadius,
  36. Color? cursorColor,
  37. Brightness? keyboardAppearance,
  38. EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  39. bool enableInteractiveSelection = true,
  40. InputCounterWidgetBuilder? buildCounter,
})

Implementation

DateTimeField({
  required this.format,
  required this.onShowPicker,

  // From super
  Key? key,
  FormFieldSetter<DateTime>? onSaved,
  FormFieldValidator<DateTime>? validator,
  DateTime? initialValue,
  AutovalidateMode? autovalidateMode,
  bool enabled = true,

  // Features
  this.resetIcon = const Icon(Icons.close),
  this.onChanged,

  // From TextFormField
  // Key key,
  this.controller,
  // String initialValue,
  this.focusNode,
  InputDecoration? decoration = const InputDecoration(),
  TextInputType? keyboardType,
  TextCapitalization textCapitalization = TextCapitalization.none,
  TextInputAction? textInputAction,
  TextStyle? style,
  StrutStyle? strutStyle,
  TextDirection? textDirection,
  TextAlign textAlign = TextAlign.start,
  bool autofocus = false,
  this.readOnly = true,
  bool? showCursor,
  bool obscureText = false,
  bool autocorrect = true,
  // bool autovalidate = false,
  MaxLengthEnforcement maxLengthEnforcement = MaxLengthEnforcement.enforced,
  int maxLines = 1,
  int? minLines,
  bool expands = false,
  int? maxLength,
  VoidCallback? onEditingComplete,
  ValueChanged<DateTime?>? onFieldSubmitted,
  // FormFieldSetter<String> onSaved,
  // FormFieldValidator<String> validator,
  List<TextInputFormatter>? inputFormatters,
  // bool enabled = true,
  double cursorWidth = 2.0,
  Radius? cursorRadius,
  Color? cursorColor,
  Brightness? keyboardAppearance,
  EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  bool enableInteractiveSelection = true,
  InputCounterWidgetBuilder? buildCounter,
}) : super(
          key: key,
          autovalidateMode: autovalidateMode,
          initialValue: initialValue,
          enabled: enabled,
          validator: validator,
          onSaved: onSaved,
          builder: (field) {
            final _DateTimeFieldState state = field as _DateTimeFieldState;
            final InputDecoration effectiveDecoration = (decoration ??
                    const InputDecoration())
                .applyDefaults(Theme.of(field.context).inputDecorationTheme);
            return TextField(
              controller: state._effectiveController,
              focusNode: state._effectiveFocusNode,
              decoration: effectiveDecoration.copyWith(
                errorText: field.errorText,
                suffixIcon: state.shouldShowClearIcon(effectiveDecoration)
                    ? IconButton(
                        icon: resetIcon!,
                        onPressed: state.clear,
                      )
                    : null,
              ),
              keyboardType: keyboardType,
              textInputAction: textInputAction,
              style: style,
              strutStyle: strutStyle,
              textAlign: textAlign,
              textDirection: textDirection,
              textCapitalization: textCapitalization,
              autofocus: autofocus,
              readOnly: readOnly,
              showCursor: showCursor,
              obscureText: obscureText,
              autocorrect: autocorrect,
              maxLengthEnforcement: maxLengthEnforcement,
              maxLines: maxLines,
              minLines: minLines,
              expands: expands,
              maxLength: maxLength,
              onChanged: (string) =>
                  field.didChange(tryParse(string, format)),
              onEditingComplete: onEditingComplete,
              onSubmitted: (string) => onFieldSubmitted == null
                  ? null
                  : onFieldSubmitted(tryParse(string, format)),
              inputFormatters: inputFormatters,
              enabled: enabled,
              cursorWidth: cursorWidth,
              cursorRadius: cursorRadius,
              cursorColor: cursorColor,
              scrollPadding: scrollPadding,
              keyboardAppearance: keyboardAppearance,
              enableInteractiveSelection: enableInteractiveSelection,
              buildCounter: buildCounter,
            );
          });