ArnaTextFormField constructor

ArnaTextFormField({
  1. Key? key,
  2. FormFieldSetter<String>? onSaved,
  3. FormFieldValidator<String>? validator,
  4. AutovalidateMode? autovalidateMode,
  5. TextEditingController? controller,
  6. String? initialValue,
  7. FocusNode? focusNode,
  8. String? hintText,
  9. Widget? prefix,
  10. ArnaOverlayVisibilityMode prefixMode = ArnaOverlayVisibilityMode.always,
  11. Widget? suffix,
  12. ArnaOverlayVisibilityMode suffixMode = ArnaOverlayVisibilityMode.always,
  13. ArnaOverlayVisibilityMode clearButtonMode = ArnaOverlayVisibilityMode.never,
  14. TextInputType? keyboardType,
  15. TextInputAction? textInputAction,
  16. TextCapitalization textCapitalization = TextCapitalization.none,
  17. StrutStyle? strutStyle,
  18. TextAlign textAlign = TextAlign.start,
  19. TextAlignVertical? textAlignVertical,
  20. TextDirection? textDirection,
  21. bool readOnly = false,
  22. ToolbarOptions? toolbarOptions,
  23. bool? showCursor,
  24. bool autofocus = false,
  25. String obscuringCharacter = '•',
  26. bool obscureText = false,
  27. bool autocorrect = true,
  28. SmartDashesType? smartDashesType,
  29. SmartQuotesType? smartQuotesType,
  30. bool enableSuggestions = true,
  31. int? maxLines = 1,
  32. int? minLines,
  33. bool expands = false,
  34. int? maxLength,
  35. MaxLengthEnforcement? maxLengthEnforcement,
  36. ValueChanged<String>? onChanged,
  37. VoidCallback? onEditingComplete,
  38. ValueChanged<String>? onFieldSubmitted,
  39. List<TextInputFormatter>? inputFormatters,
  40. bool? enabled,
  41. double cursorWidth = Styles.cursorWidth,
  42. double? cursorHeight,
  43. Radius? cursorRadius = const Radius.circular(Styles.cursorRadius),
  44. Color? accentColor,
  45. Brightness? keyboardAppearance,
  46. EdgeInsets scrollPadding = const EdgeInsets.all(Styles.padding),
  47. bool? enableInteractiveSelection,
  48. TextSelectionControls? selectionControls,
  49. GestureTapCallback? onTap,
  50. MouseCursor cursor = MouseCursor.defer,
  51. ScrollController? scrollController,
  52. ScrollPhysics? scrollPhysics,
  53. Iterable<String>? autofillHints,
  54. String? restorationId,
  55. bool enableIMEPersonalizedLearning = true,
})

Creates a FormField that contains an ArnaTextField.

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 ArnaTextField class.

Implementation

ArnaTextFormField({
  super.key,
  super.onSaved,
  super.validator,
  AutovalidateMode? autovalidateMode,
  this.controller,
  String? initialValue,
  FocusNode? focusNode,
  String? hintText,
  Widget? prefix,
  ArnaOverlayVisibilityMode prefixMode = ArnaOverlayVisibilityMode.always,
  Widget? suffix,
  ArnaOverlayVisibilityMode suffixMode = ArnaOverlayVisibilityMode.always,
  ArnaOverlayVisibilityMode clearButtonMode = ArnaOverlayVisibilityMode.never,
  TextInputType? keyboardType,
  TextInputAction? textInputAction,
  TextCapitalization textCapitalization = TextCapitalization.none,
  StrutStyle? strutStyle,
  TextAlign textAlign = TextAlign.start,
  TextAlignVertical? textAlignVertical,
  TextDirection? textDirection,
  bool readOnly = false,
  ToolbarOptions? toolbarOptions,
  bool? showCursor,
  bool autofocus = false,
  String obscuringCharacter = '•',
  bool obscureText = false,
  bool autocorrect = true,
  SmartDashesType? smartDashesType,
  SmartQuotesType? smartQuotesType,
  bool enableSuggestions = true,
  int? maxLines = 1,
  int? minLines,
  bool expands = false,
  int? maxLength,
  MaxLengthEnforcement? maxLengthEnforcement,
  ValueChanged<String>? onChanged,
  VoidCallback? onEditingComplete,
  ValueChanged<String>? onFieldSubmitted,
  List<TextInputFormatter>? inputFormatters,
  bool? enabled,
  double cursorWidth = Styles.cursorWidth,
  double? cursorHeight,
  Radius? cursorRadius = const Radius.circular(Styles.cursorRadius),
  Color? accentColor,
  Brightness? keyboardAppearance,
  EdgeInsets scrollPadding = const EdgeInsets.all(Styles.padding),
  bool? enableInteractiveSelection,
  TextSelectionControls? selectionControls,
  GestureTapCallback? onTap,
  MouseCursor cursor = MouseCursor.defer,
  ScrollController? scrollController,
  ScrollPhysics? scrollPhysics,
  Iterable<String>? autofillHints,
  super.restorationId,
  bool enableIMEPersonalizedLearning = true,
})  : assert(initialValue == null || controller == null),
      assert(obscuringCharacter.length == 1),
      assert(maxLines == null || maxLines > 0),
      assert(minLines == null || minLines > 0),
      assert(
        (maxLines == null) || (minLines == null) || (maxLines >= minLines),
        "minLines can't be greater than maxLines",
      ),
      assert(
        !expands || (maxLines == null && 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(
        initialValue:
            controller != null ? controller.text : (initialValue ?? ''),
        enabled: enabled ?? true,
        autovalidateMode: autovalidateMode ?? AutovalidateMode.disabled,
        builder: (FormFieldState<String> field) {
          final _ArnaTextFormFieldState state =
              field as _ArnaTextFormFieldState;
          void onChangedHandler(String value) {
            field.didChange(value);
            if (onChanged != null) {
              onChanged(value);
            }
          }

          return UnmanagedRestorationScope(
            bucket: field.bucket,
            child: ArnaTextField(
              controller: state._effectiveController,
              focusNode: focusNode,
              hintText: hintText,
              prefix: prefix,
              prefixMode: prefixMode,
              suffix: suffix,
              suffixMode: suffixMode,
              clearButtonMode: clearButtonMode,
              keyboardType: keyboardType,
              textInputAction: textInputAction,
              textCapitalization: textCapitalization,
              strutStyle: strutStyle,
              textAlign: textAlign,
              textAlignVertical: textAlignVertical,
              textDirection: textDirection,
              readOnly: readOnly,
              toolbarOptions: toolbarOptions,
              showCursor: showCursor,
              autofocus: autofocus,
              obscuringCharacter: obscuringCharacter,
              obscureText: obscureText,
              autocorrect: autocorrect,
              smartDashesType: smartDashesType ??
                  (obscureText
                      ? SmartDashesType.disabled
                      : SmartDashesType.enabled),
              smartQuotesType: smartQuotesType ??
                  (obscureText
                      ? SmartQuotesType.disabled
                      : SmartQuotesType.enabled),
              enableSuggestions: enableSuggestions,
              maxLines: maxLines,
              minLines: minLines,
              expands: expands,
              maxLength: maxLength,
              maxLengthEnforcement: maxLengthEnforcement,
              onChanged: onChangedHandler,
              onEditingComplete: onEditingComplete,
              onSubmitted: onFieldSubmitted,
              inputFormatters: inputFormatters,
              enabled: enabled ?? true,
              cursorWidth: cursorWidth,
              cursorHeight: cursorHeight,
              cursorRadius: cursorRadius,
              accentColor: accentColor,
              keyboardAppearance: keyboardAppearance,
              scrollPadding: scrollPadding,
              enableInteractiveSelection:
                  enableInteractiveSelection ?? (!obscureText || !readOnly),
              selectionControls: selectionControls,
              onTap: onTap,
              cursor: cursor,
              scrollController: scrollController,
              scrollPhysics: scrollPhysics,
              autofillHints: autofillHints,
              restorationId: restorationId,
              enableIMEPersonalizedLearning: enableIMEPersonalizedLearning,
            ),
          );
        },
      );