MongolTextField constructor

const MongolTextField({
  1. Key? key,
  2. TextEditingController? controller,
  3. FocusNode? focusNode,
  4. InputDecoration? decoration = const InputDecoration(),
  5. TextInputType? keyboardType,
  6. TextInputAction? textInputAction,
  7. TextStyle? style,
  8. MongolTextAlign textAlign = MongolTextAlign.top,
  9. TextAlignHorizontal? textAlignHorizontal,
  10. bool readOnly = false,
  11. ToolbarOptions? toolbarOptions,
  12. bool? showCursor,
  13. bool autofocus = false,
  14. String obscuringCharacter = '•',
  15. bool obscureText = false,
  16. bool autocorrect = true,
  17. bool enableSuggestions = true,
  18. int? maxLines = 1,
  19. int? minLines,
  20. bool expands = false,
  21. int? maxLength,
  22. MaxLengthEnforcement? maxLengthEnforcement,
  23. ValueChanged<String>? onChanged,
  24. VoidCallback? onEditingComplete,
  25. ValueChanged<String>? onSubmitted,
  26. AppPrivateCommandCallback? onAppPrivateCommand,
  27. List<TextInputFormatter>? inputFormatters,
  28. bool? enabled,
  29. double cursorHeight = 2.0,
  30. double? cursorWidth,
  31. Radius? cursorRadius,
  32. Color? cursorColor,
  33. Brightness? keyboardAppearance,
  34. EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  35. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  36. bool enableInteractiveSelection = true,
  37. TextSelectionControls? selectionControls,
  38. GestureTapCallback? onTap,
  39. MouseCursor? mouseCursor,
  40. InputCounterWidgetBuilder? buildCounter,
  41. ScrollController? scrollController,
  42. ScrollPhysics? scrollPhysics,
  43. Iterable<String>? autofillHints,
  44. String? restorationId,
  45. ContentInsertionConfiguration? contentInsertionConfiguration,
})

Creates a Material Design text field for vertical Mongolian text.

If decoration is non-null (which is the default), the text field requires one of its ancestors to be a Material widget.

To remove the decoration entirely (including the extra padding introduced by the decoration to save space for the labels), set the decoration to null.

The maxLines property can be set to null to remove the restriction on the number of lines. By default, it is one, meaning this is a single-line text field. maxLines must not be zero.

The maxLength property is set to null by default, which means the number of characters allowed in the text field is not restricted. If maxLength is set a character counter will be displayed to the right of the field showing how many characters have been entered. If the value is set to a positive integer it will also display the maximum allowed number of characters to be entered. If the value is set to TextField.noMaxLength then only the current length is displayed.

After maxLength characters have been input, additional input is ignored, unless maxLengthEnforcement is set to MaxLengthEnforcement.none. The text field enforces the length with a LengthLimitingTextInputFormatter, which is evaluated after the supplied inputFormatters, if any. The maxLength value must be either null or greater than zero.

The text cursor is not shown if showCursor is false or if showCursor is null (the default) and readOnly is true.

The textAlign, autofocus, obscureText, readOnly, autocorrect, scrollPadding, maxLines, maxLength, and enableSuggestions arguments must not be null.

See also:

  • maxLength, which discusses the precise meaning of "number of characters" and how it may differ from the intuitive meaning.

Implementation

const MongolTextField({
  Key? key,
  this.controller,
  this.focusNode,
  this.decoration = const InputDecoration(),
  TextInputType? keyboardType,
  this.textInputAction,
  this.style,
  this.textAlign = MongolTextAlign.top,
  this.textAlignHorizontal,
  this.readOnly = false,
  ToolbarOptions? toolbarOptions,
  this.showCursor,
  this.autofocus = false,
  this.obscuringCharacter = '•',
  this.obscureText = false,
  this.autocorrect = true,
  this.enableSuggestions = true,
  this.maxLines = 1,
  this.minLines,
  this.expands = false,
  this.maxLength,
  this.maxLengthEnforcement,
  this.onChanged,
  this.onEditingComplete,
  this.onSubmitted,
  this.onAppPrivateCommand,
  this.inputFormatters,
  this.enabled,
  this.cursorHeight = 2.0,
  this.cursorWidth,
  this.cursorRadius,
  this.cursorColor,
  this.keyboardAppearance,
  this.scrollPadding = const EdgeInsets.all(20.0),
  this.dragStartBehavior = DragStartBehavior.start,
  this.enableInteractiveSelection = true,
  this.selectionControls,
  this.onTap,
  this.mouseCursor,
  this.buildCounter,
  this.scrollController,
  this.scrollPhysics,
  this.autofillHints,
  this.restorationId,
  this.contentInsertionConfiguration,
})  : 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 == MongolTextField.noMaxLength ||
          maxLength > 0),
      // Assert the following instead of setting it directly to avoid surprising the user by silently changing the value they set.
      assert(
          !identical(textInputAction, TextInputAction.newline) ||
              maxLines == 1 ||
              !identical(keyboardType, TextInputType.text),
          'Use keyboardType TextInputType.multiline when using TextInputAction.newline on a multiline TextField.'),
      keyboardType = keyboardType ??
          (maxLines == 1 ? TextInputType.text : TextInputType.multiline),
      toolbarOptions = toolbarOptions ??
          (obscureText
              ? const ToolbarOptions(
                  selectAll: true,
                  paste: true,
                )
              : const ToolbarOptions(
                  copy: true,
                  cut: true,
                  selectAll: true,
                  paste: true,
                )),
      super(key: key);