DateTimeField constructor
DateTimeField({
- required DateFormat format,
- required Future<
DateTime?> onShowPicker(- BuildContext context,
- DateTime? currentValue
- Key? key,
- FormFieldSetter<
DateTime> ? onSaved, - FormFieldValidator<
DateTime> ? validator, - DateTime? initialValue,
- AutovalidateMode? autovalidateMode,
- bool enabled = true,
- Icon? resetIcon = const Icon(Icons.close),
- void onChanged(
- DateTime? value
- TextEditingController? controller,
- FocusNode? 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,
- bool readOnly = true,
- bool? showCursor,
- bool obscureText = false,
- bool autocorrect = true,
- MaxLengthEnforcement maxLengthEnforcement = MaxLengthEnforcement.enforced,
- int maxLines = 1,
- int? minLines,
- bool expands = false,
- int? maxLength,
- VoidCallback? onEditingComplete,
- ValueChanged<
DateTime?> ? onFieldSubmitted, - List<
TextInputFormatter> ? inputFormatters, - double cursorWidth = 2.0,
- Radius? cursorRadius,
- Color? cursorColor,
- Brightness? keyboardAppearance,
- EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
- bool enableInteractiveSelection = true,
- 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,
);
});