Field.date constructor

Field.date(
  1. String key, {
  2. String? label,
  3. dynamic value,
  4. FormValidator? validate,
  5. bool autofocus = false,
  6. String? dummyData,
  7. Widget? header,
  8. Widget? footer,
  9. TextStyle? titleStyle,
  10. dynamic style,
  11. Map<String, NyTextField Function(NyTextField nyTextField)>? metaData = const {},
  12. bool? hidden = false,
  13. bool? readOnly,
  14. TextStyle? dateTextStyle,
  15. VoidCallback? onTap,
  16. FocusNode? focusNode,
  17. bool? enableFeedback,
  18. EdgeInsetsGeometry? padding,
  19. bool hideDefaultSuffixIcon = false,
  20. DateTime? initialPickerDateTime,
  21. CupertinoDatePickerOptions? cupertinoDatePickerOptions,
  22. MaterialDatePickerOptions? materialDatePickerOptions,
  23. MaterialTimePickerOptions? materialTimePickerOptions,
  24. InputDecoration? decoration,
  25. DateFormat? dateFormat,
  26. DateTime? firstDate,
  27. DateTime? lastDate,
  28. DateTimeFieldPickerMode mode = DateTimeFieldPickerMode.dateAndTime,
  29. DateTimeFieldPickerPlatform pickerPlatform = DateTimeFieldPickerPlatform.adaptive,
})

Field.date is a constructor that helps in managing date fields

Implementation

Field.date(
  this.key, {
  this.label,
  this.value,
  this.validate,
  this.autofocus = false,
  this.dummyData,
  this.header,
  this.footer,
  this.titleStyle,
  this.style,
  this.metaData = const {},
  this.hidden = false,
  this.readOnly,
  TextStyle? dateTextStyle,
  VoidCallback? onTap,
  FocusNode? focusNode,
  bool? enableFeedback,
  EdgeInsetsGeometry? padding,
  bool hideDefaultSuffixIcon = false,
  DateTime? initialPickerDateTime,
  CupertinoDatePickerOptions? cupertinoDatePickerOptions,
  MaterialDatePickerOptions? materialDatePickerOptions,
  MaterialTimePickerOptions? materialTimePickerOptions,
  InputDecoration? decoration,
  intl.DateFormat? dateFormat,
  DateTime? firstDate,
  DateTime? lastDate,
  DateTimeFieldPickerMode mode = DateTimeFieldPickerMode.dateAndTime,
  DateTimeFieldPickerPlatform pickerPlatform =
      DateTimeFieldPickerPlatform.adaptive,
}) : cast = FormCast.date(
          style: dateTextStyle,
          onTap: onTap,
          focusNode: focusNode,
          autofocus: autofocus,
          enableFeedback: enableFeedback,
          padding: padding,
          hideDefaultSuffixIcon: hideDefaultSuffixIcon,
          initialPickerDateTime: initialPickerDateTime,
          cupertinoDatePickerOptions: cupertinoDatePickerOptions,
          materialDatePickerOptions: materialDatePickerOptions,
          materialTimePickerOptions: materialTimePickerOptions,
          decoration: decoration,
          dateFormat: dateFormat,
          firstDate: firstDate,
          lastDate: lastDate,
          mode: mode,
          pickerPlatform: pickerPlatform) {
  if (style == null) return;

  metaData = {};
  if (style is String) {
    style = style;
    return;
  }
  if (style is Map) {
    style as Map<String, dynamic>;
    metaData!["decoration_style"] =
        (style as Map<String, dynamic>).entries.first.value;
    style = (style as Map<String, dynamic>).entries.first.key;
  }
}