Field.datetime constructor

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

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

Implementation

Field.datetime(
  this.key, {
  this.value,
  this.validate,
  this.autofocus = false,
  this.dummyData,
  this.header,
  this.footer,
  this.titleStyle,
  this.style,
  this.metaData = const {},
  this.hidden = false,
  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.datetime(
          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;
  }
}