CronFormField constructor

CronFormField({
  1. Key? key,
  2. TextEditingController? controller,
  3. Widget? icon,
  4. String? labelText,
  5. String? hintText,
  6. String? dialogTitle,
  7. String dialogCancelText = 'Cancel',
  8. String dialogDoneText = 'Done',
  9. ValueChanged<String>? onChanged,
  10. CronExpressionOutputFormat? outputFormat = CronExpressionOutputFormat.AUTO,
  11. String? initialValue,
  12. FocusNode? focusNode,
  13. InputDecoration? decoration,
  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. TextAlignVertical? textAlignVertical,
  22. bool autofocus = false,
  23. bool readOnly = false,
  24. Widget contextMenuBuilder(
    1. BuildContext,
    2. EditableTextState
    )?,
  25. bool? showCursor,
  26. bool obscureText = false,
  27. bool autocorrect = true,
  28. SmartDashesType? smartDashesType,
  29. SmartQuotesType? smartQuotesType,
  30. bool enableSuggestions = true,
  31. bool autovalidate = false,
  32. bool maxLengthEnforced = true,
  33. int maxLines = 1,
  34. int? minLines,
  35. bool expands = false,
  36. int? maxLength,
  37. VoidCallback? onEditingComplete,
  38. ValueChanged<String>? onFieldSubmitted,
  39. FormFieldSetter<String>? onSaved,
  40. FormFieldValidator<String>? validator,
  41. List<TextInputFormatter>? inputFormatters,
  42. bool enabled = true,
  43. double cursorWidth = 2.0,
  44. Radius? cursorRadius,
  45. Color? cursorColor,
  46. Brightness? keyboardAppearance,
  47. EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  48. bool enableInteractiveSelection = true,
  49. InputCounterWidgetBuilder? buildCounter,
  50. ScrollPhysics? scrollPhysics,
})

Creates a CronFormField that contains a TextField.

When a controller is specified, initialValue must be null (the default). If controller is null, then a TextEditingController will be constructed automatically and its text will be initialized to initialValue or the empty string.

For documentation about the various parameters, see the TextField class and new TextField, the constructor.

Implementation

CronFormField({
  Key? key,
  this.controller,
  this.icon,
  this.labelText,
  this.hintText,
  this.dialogTitle,
  this.dialogCancelText = 'Cancel',
  this.dialogDoneText = 'Done',
  this.onChanged,
  this.outputFormat = CronExpressionOutputFormat.AUTO,
  String? initialValue,
  FocusNode? focusNode,
  InputDecoration? decoration,
  TextInputType? keyboardType,
  TextCapitalization textCapitalization = TextCapitalization.none,
  TextInputAction? textInputAction,
  TextStyle? style,
  StrutStyle? strutStyle,
  TextDirection? textDirection,
  TextAlign textAlign = TextAlign.start,
  TextAlignVertical? textAlignVertical,
  bool autofocus = false,
  bool readOnly = false,
  Widget Function(BuildContext, EditableTextState)? contextMenuBuilder,
  bool? showCursor,
  bool obscureText = false,
  bool autocorrect = true,
  SmartDashesType? smartDashesType,
  SmartQuotesType? smartQuotesType,
  bool enableSuggestions = true,
  bool autovalidate = false,
  bool maxLengthEnforced = true,
  int maxLines = 1,
  int? minLines,
  bool expands = false,
  int? maxLength,
  //GestureTapCallback onTap,
  VoidCallback? onEditingComplete,
  ValueChanged<String>? 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,
  ScrollPhysics? scrollPhysics,
})  : assert(initialValue == null || controller == null),
      assert(maxLines > 0),
      assert(minLines == null || minLines > 0),
      assert(
        (minLines == null) || (maxLines >= minLines),
        "minLines can't be greater than maxLines",
      ),
      assert(
        !expands || minLines == null,
        'minLines and maxLines must be null when expands is true.',
      ),
      assert(
        !obscureText || maxLines == 1,
        'Obscured fields cannot be multiline.',
      ),
      assert(maxLength == null || maxLength > 0),
      super(
        key: key,
        initialValue:
            controller != null ? controller.text : (initialValue ?? ''),
        onSaved: onSaved,
        validator: validator,
        // autovalidate: autovalidate,
        enabled: enabled,
        builder: (FormFieldState<String> formFieldState) {
          final CronFormFieldState state =
              formFieldState as CronFormFieldState;

          final InputDecoration effectiveDecoration = decoration ??
              InputDecoration(
                labelText: labelText,
                icon: icon,
                hintText: hintText,
                suffixIcon: const Icon(Icons.arrow_drop_down),
              );
          effectiveDecoration.applyDefaults(
            Theme.of(state.context).inputDecorationTheme,
          );

          return TextField(
            controller: state._controller,
            focusNode: focusNode,
            decoration: effectiveDecoration.copyWith(
              errorText: state.errorText,
            ),
            keyboardType: keyboardType,
            textInputAction: textInputAction,
            style: style,
            strutStyle: strutStyle,
            textAlign: textAlign,
            textAlignVertical: textAlignVertical,
            textDirection: textDirection,
            textCapitalization: textCapitalization,
            autofocus: autofocus,
            contextMenuBuilder: contextMenuBuilder,
            readOnly: true,
            showCursor: showCursor,
            obscureText: obscureText,
            autocorrect: autocorrect,
            smartDashesType: smartDashesType ??
                (obscureText
                    ? SmartDashesType.disabled
                    : SmartDashesType.enabled),
            smartQuotesType: smartQuotesType ??
                (obscureText
                    ? SmartQuotesType.disabled
                    : SmartQuotesType.enabled),
            enableSuggestions: enableSuggestions,
            // maxLengthEnforced: maxLengthEnforced,
            maxLines: maxLines,
            minLines: minLines,
            expands: expands,
            maxLength: maxLength,
            onChanged: state.onChangedHandler,
            onTap: readOnly ? null : state._showCronFormFieldDialog,
            onEditingComplete: onEditingComplete,
            onSubmitted: onFieldSubmitted,
            inputFormatters: inputFormatters,
            enabled: enabled,
            cursorWidth: cursorWidth,
            cursorRadius: cursorRadius,
            cursorColor: cursorColor,
            scrollPadding: scrollPadding,
            scrollPhysics: scrollPhysics,
            keyboardAppearance: keyboardAppearance,
            enableInteractiveSelection: enableInteractiveSelection,
            buildCounter: buildCounter,
          );
        },
      );