FormeDateTimeRangeField constructor

FormeDateTimeRangeField({
  1. DateTimeRange? initialValue,
  2. DateTime? firstDate,
  3. DateTime? lastDate,
  4. FormeDateRangeFormatter? formatter,
  5. required String name,
  6. bool readOnly = false,
  7. Key? key,
  8. InputDecoration? decoration,
  9. int? maxLines = 1,
  10. int? order,
  11. bool quietlyValidate = false,
  12. bool autofocus = false,
  13. int? minLines,
  14. int? maxLength,
  15. TextStyle? style,
  16. ToolbarOptions? toolbarOptions,
  17. TextInputAction? textInputAction,
  18. TextCapitalization textCapitalization = TextCapitalization.none,
  19. bool obscureText = false,
  20. StrutStyle? strutStyle,
  21. TextAlign textAlign = TextAlign.start,
  22. TextAlignVertical? textAlignVertical,
  23. TextDirection? textDirection,
  24. bool? showCursor,
  25. String obscuringCharacter = '•',
  26. bool autocorrect = true,
  27. SmartDashesType? smartDashesType,
  28. SmartQuotesType? smartQuotesType,
  29. bool enableSuggestions = true,
  30. bool expands = false,
  31. MaxLengthEnforcement? maxLengthEnforcement,
  32. double cursorWidth = 2.0,
  33. double? cursorHeight,
  34. Radius? cursorRadius,
  35. Color? cursorColor,
  36. BoxHeightStyle selectionHeightStyle = BoxHeightStyle.tight,
  37. BoxWidthStyle selectionWidthStyle = BoxWidthStyle.tight,
  38. Brightness? keyboardAppearance,
  39. EdgeInsets scrollPadding = const EdgeInsets.all(20),
  40. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  41. MouseCursor? mouseCursor,
  42. ScrollPhysics? scrollPhysics,
  43. Iterable<String>? autofillHints,
  44. bool enableInteractiveSelection = true,
  45. bool enabled = true,
  46. VoidCallback? onEditingComplete,
  47. AppPrivateCommandCallback? appPrivateCommandCallback,
  48. InputCounterWidgetBuilder? buildCounter,
  49. ValueChanged<DateTimeRange?>? onSubmitted,
  50. ScrollController? scrollController,
  51. TextSelectionControls? textSelectionControls,
  52. Duration? asyncValidatorDebounce,
  53. AutovalidateMode? autovalidateMode,
  54. FormeFieldStatusChanged<DateTimeRange?>? onStatusChanged,
  55. dynamic onInitialed,
  56. FormeFieldSetter<DateTimeRange?>? onSaved,
  57. FormeValidator<DateTimeRange?>? validator,
  58. FormeAsyncValidator<DateTimeRange?>? asyncValidator,
  59. DatePickerEntryMode? initialEntryMode,
  60. String? helpText,
  61. String? cancelText,
  62. String? confirmText,
  63. String? saveText,
  64. String? errorFormatText,
  65. String? errorInvalidText,
  66. String? errorInvalidRangeText,
  67. String? fieldStartHintText,
  68. String? fieldEndHintText,
  69. String? fieldStartLabelText,
  70. String? fieldEndLabelText,
  71. RouteSettings? routeSettings,
  72. TransitionBuilder? builder,
  73. FormeFieldDecorator<DateTimeRange?>? decorator,
  74. bool registrable = true,
  75. dynamic valueUpdater,
  76. FormeFieldValidationFilter<DateTimeRange?>? validationFilter,
  77. FocusNode? focusNode,
})

Implementation

FormeDateTimeRangeField({
  DateTimeRange? initialValue,
  this.firstDate,
  this.lastDate,
  this.formatter,
  required String name,
  bool readOnly = false,
  Key? key,
  InputDecoration? decoration,
  int? maxLines = 1,
  int? order,
  bool quietlyValidate = false,
  bool autofocus = false,
  int? minLines,
  int? maxLength,
  TextStyle? style,
  ToolbarOptions? toolbarOptions,
  TextInputAction? textInputAction,
  TextCapitalization textCapitalization = TextCapitalization.none,
  bool obscureText = false,
  StrutStyle? strutStyle,
  TextAlign textAlign = TextAlign.start,
  TextAlignVertical? textAlignVertical,
  TextDirection? textDirection,
  bool? showCursor,
  String obscuringCharacter = '•',
  bool autocorrect = true,
  SmartDashesType? smartDashesType,
  SmartQuotesType? smartQuotesType,
  bool enableSuggestions = true,
  bool expands = false,
  MaxLengthEnforcement? maxLengthEnforcement,
  double cursorWidth = 2.0,
  double? cursorHeight,
  Radius? cursorRadius,
  Color? cursorColor,
  BoxHeightStyle selectionHeightStyle = BoxHeightStyle.tight,
  BoxWidthStyle selectionWidthStyle = BoxWidthStyle.tight,
  Brightness? keyboardAppearance,
  EdgeInsets scrollPadding = const EdgeInsets.all(20),
  DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  MouseCursor? mouseCursor,
  ScrollPhysics? scrollPhysics,
  Iterable<String>? autofillHints,
  bool enableInteractiveSelection = true,
  bool enabled = true,
  VoidCallback? onEditingComplete,
  AppPrivateCommandCallback? appPrivateCommandCallback,
  InputCounterWidgetBuilder? buildCounter,
  ValueChanged<DateTimeRange?>? onSubmitted,
  ScrollController? scrollController,
  TextSelectionControls? textSelectionControls,
  Duration? asyncValidatorDebounce,
  AutovalidateMode? autovalidateMode,
  FormeFieldStatusChanged<DateTimeRange?>? onStatusChanged,
  FormeFieldInitialed<DateTimeRange?>? onInitialed,
  FormeFieldSetter<DateTimeRange?>? onSaved,
  FormeValidator<DateTimeRange?>? validator,
  FormeAsyncValidator<DateTimeRange?>? asyncValidator,
  DatePickerEntryMode? initialEntryMode,
  String? helpText,
  String? cancelText,
  String? confirmText,
  String? saveText,
  String? errorFormatText,
  String? errorInvalidText,
  String? errorInvalidRangeText,
  String? fieldStartHintText,
  String? fieldEndHintText,
  String? fieldStartLabelText,
  String? fieldEndLabelText,
  RouteSettings? routeSettings,
  TransitionBuilder? builder,
  FormeFieldDecorator<DateTimeRange?>? decorator,
  bool registrable = true,
  FormeFieldValueUpdater<DateTimeRange?>? valueUpdater,
  FormeFieldValidationFilter<DateTimeRange?>? validationFilter,
  FocusNode? focusNode,
}) : super(
        focusNode: focusNode,
        validationFilter: validationFilter,
        valueUpdater: valueUpdater,
        enabled: enabled,
        registrable: registrable,
        decorator: decorator,
        order: order,
        quietlyValidate: quietlyValidate,
        asyncValidatorDebounce: asyncValidatorDebounce,
        autovalidateMode: autovalidateMode,
        onStatusChanged: onStatusChanged,
        onInitialed: onInitialed,
        onSaved: onSaved,
        validator: validator,
        asyncValidator: asyncValidator,
        key: key,
        name: name,
        readOnly: readOnly,
        initialValue: initialValue,
        builder: (baseState) {
          final bool readOnly = baseState.readOnly;
          final bool enabled = baseState.enabled;
          final _FormeDateTimeRangeFieldState state =
              baseState as _FormeDateTimeRangeFieldState;

          final DateTime _firstDate = firstDate ?? DateTime(1970);
          final DateTime _lastDate = lastDate ?? DateTime(2099);

          void pickRange() {
            showDateRangePicker(
              initialDateRange: state.value,
              context: state.context,
              firstDate: _firstDate,
              lastDate: _lastDate,
              builder: builder,
              initialEntryMode:
                  initialEntryMode ?? DatePickerEntryMode.calendar,
              helpText: helpText,
              cancelText: cancelText,
              confirmText: confirmText,
              saveText: saveText,
              errorFormatText: errorFormatText,
              errorInvalidText: errorInvalidText,
              errorInvalidRangeText: errorInvalidRangeText,
              fieldStartHintText: fieldStartHintText,
              fieldEndHintText: fieldEndHintText,
              fieldStartLabelText: fieldStartLabelText,
              fieldEndLabelText: fieldEndLabelText,
              routeSettings: routeSettings,
              textDirection: textDirection,
            ).then((value) {
              if (value != null) {
                state.didChange(value);
              }
              state.focusNode.requestFocus();
            });
          }

          return TextField(
            focusNode: state.focusNode,
            controller: state.textEditingController,
            decoration: decoration?.copyWith(errorText: state.errorText),
            obscureText: obscureText,
            maxLines: maxLines,
            minLines: minLines,
            enabled: enabled,
            readOnly: true,
            onTap: readOnly ? null : pickRange,
            onEditingComplete: onEditingComplete,
            onSubmitted:
                onSubmitted == null ? null : (v) => onSubmitted(state.value),
            onAppPrivateCommand: appPrivateCommandCallback,
            textInputAction: textInputAction,
            textCapitalization: textCapitalization,
            style: style,
            strutStyle: strutStyle,
            textAlign: textAlign,
            textAlignVertical: textAlignVertical,
            textDirection: textDirection,
            showCursor: showCursor,
            obscuringCharacter: obscuringCharacter,
            autocorrect: autocorrect,
            smartDashesType: smartDashesType,
            smartQuotesType: smartQuotesType,
            enableSuggestions: enableSuggestions,
            expands: expands,
            cursorWidth: cursorWidth,
            cursorHeight: cursorHeight,
            cursorRadius: cursorRadius,
            cursorColor: cursorColor,
            selectionHeightStyle: selectionHeightStyle,
            selectionWidthStyle: selectionWidthStyle,
            keyboardAppearance: keyboardAppearance,
            scrollPadding: scrollPadding,
            dragStartBehavior: dragStartBehavior,
            mouseCursor: mouseCursor,
            scrollPhysics: scrollPhysics,
            autofillHints: readOnly ? null : autofillHints,
            autofocus: autofocus,
            toolbarOptions: toolbarOptions,
            enableInteractiveSelection: enableInteractiveSelection,
            buildCounter: buildCounter,
            maxLengthEnforcement: maxLengthEnforcement,
            maxLength: maxLength,
            scrollController: scrollController,
            selectionControls: textSelectionControls,
          );
        },
      );