EditableText constructor

EditableText(
  1. {Key key,
  2. @required TextEditingController controller,
  3. @required FocusNode focusNode,
  4. bool readOnly: false,
  5. String obscuringCharacter: '•',
  6. bool obscureText: false,
  7. bool autocorrect: true,
  8. SmartDashesType smartDashesType,
  9. SmartQuotesType smartQuotesType,
  10. bool enableSuggestions: true,
  11. @required TextStyle style,
  12. StrutStyle strutStyle,
  13. @required Color cursorColor,
  14. @required Color backgroundCursorColor,
  15. TextAlign textAlign: TextAlign.start,
  16. TextDirection textDirection,
  17. Locale locale,
  18. double textScaleFactor,
  19. int maxLines: 1,
  20. int minLines,
  21. bool expands: false,
  22. bool forceLine: true,
  23. TextHeightBehavior textHeightBehavior,
  24. TextWidthBasis textWidthBasis: TextWidthBasis.parent,
  25. bool autofocus: false,
  26. bool showCursor,
  27. bool showSelectionHandles: false,
  28. Color selectionColor,
  29. TextSelectionControls selectionControls,
  30. TextInputType keyboardType,
  31. TextInputAction textInputAction,
  32. TextCapitalization textCapitalization: TextCapitalization.none,
  33. ValueChanged<String> onChanged,
  34. VoidCallback onEditingComplete,
  35. ValueChanged<String> onSubmitted,
  36. SelectionChangedCallback onSelectionChanged,
  37. VoidCallback onSelectionHandleTapped,
  38. List<TextInputFormatter> inputFormatters,
  39. MouseCursor mouseCursor,
  40. bool rendererIgnoresPointer: false,
  41. double cursorWidth: 2.0,
  42. Radius cursorRadius,
  43. bool cursorOpacityAnimates: false,
  44. Offset cursorOffset,
  45. bool paintCursorAboveText: false,
  46. BoxHeightStyle selectionHeightStyle: ui.BoxHeightStyle.tight,
  47. BoxWidthStyle selectionWidthStyle: ui.BoxWidthStyle.tight,
  48. EdgeInsets scrollPadding: const EdgeInsets.all(20.0),
  49. Brightness keyboardAppearance: Brightness.light,
  50. DragStartBehavior dragStartBehavior: DragStartBehavior.start,
  51. bool enableInteractiveSelection: true,
  52. ScrollController scrollController,
  53. ScrollPhysics scrollPhysics,
  54. Color autocorrectionTextRectColor,
  55. ToolbarOptions toolbarOptions: const ToolbarOptions(copy: true, cut: true, paste: true, selectAll: true),
  56. Iterable<String> autofillHints,
  57. Clip clipBehavior: Clip.hardEdge}
)

Creates a basic text input control.

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 be null or greater than zero.

If keyboardType is not set or is null, its value will be inferred from autofillHints, if autofillHints is not empty. Otherwise it defaults to TextInputType.text if maxLines is exactly one, and TextInputType.multiline if maxLines is null or greater than one.

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

The controller, focusNode, obscureText, autocorrect, autofocus, showSelectionHandles, enableInteractiveSelection, forceLine, style, cursorColor, cursorOpacityAnimates,backgroundCursorColor, enableSuggestions, paintCursorAboveText, selectionHeightStyle, selectionWidthStyle, textAlign, dragStartBehavior, scrollPadding, dragStartBehavior, toolbarOptions, rendererIgnoresPointer, and readOnly arguments must not be null.

Implementation

EditableText({
  Key key,
  @required this.controller,
  @required this.focusNode,
  this.readOnly = false,
  this.obscuringCharacter = '•',
  this.obscureText = false,
  this.autocorrect = true,
  SmartDashesType smartDashesType,
  SmartQuotesType smartQuotesType,
  this.enableSuggestions = true,
  @required this.style,
  StrutStyle strutStyle,
  @required this.cursorColor,
  @required this.backgroundCursorColor,
  this.textAlign = TextAlign.start,
  this.textDirection,
  this.locale,
  this.textScaleFactor,
  this.maxLines = 1,
  this.minLines,
  this.expands = false,
  this.forceLine = true,
  this.textHeightBehavior,
  this.textWidthBasis = TextWidthBasis.parent,
  this.autofocus = false,
  bool showCursor,
  this.showSelectionHandles = false,
  this.selectionColor,
  this.selectionControls,
  TextInputType keyboardType,
  this.textInputAction,
  this.textCapitalization = TextCapitalization.none,
  this.onChanged,
  this.onEditingComplete,
  this.onSubmitted,
  this.onSelectionChanged,
  this.onSelectionHandleTapped,
  List<TextInputFormatter> inputFormatters,
  this.mouseCursor,
  this.rendererIgnoresPointer = false,
  this.cursorWidth = 2.0,
  this.cursorRadius,
  this.cursorOpacityAnimates = false,
  this.cursorOffset,
  this.paintCursorAboveText = false,
  this.selectionHeightStyle = ui.BoxHeightStyle.tight,
  this.selectionWidthStyle = ui.BoxWidthStyle.tight,
  this.scrollPadding = const EdgeInsets.all(20.0),
  this.keyboardAppearance = Brightness.light,
  this.dragStartBehavior = DragStartBehavior.start,
  this.enableInteractiveSelection = true,
  this.scrollController,
  this.scrollPhysics,
  this.autocorrectionTextRectColor,
  this.toolbarOptions = const ToolbarOptions(
    copy: true,
    cut: true,
    paste: true,
    selectAll: true,
  ),
  this.autofillHints,
  this.clipBehavior = Clip.hardEdge,
}) : assert(controller != null),
     assert(focusNode != null),
     assert(obscuringCharacter != null && obscuringCharacter.length == 1),
     assert(obscureText != null),
     assert(autocorrect != null),
     smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled),
     smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled),
     assert(enableSuggestions != null),
     assert(showSelectionHandles != null),
     assert(enableInteractiveSelection != null),
     assert(readOnly != null),
     assert(forceLine != null),
     assert(style != null),
     assert(cursorColor != null),
     assert(cursorOpacityAnimates != null),
     assert(paintCursorAboveText != null),
     assert(backgroundCursorColor != null),
     assert(selectionHeightStyle != null),
     assert(selectionWidthStyle != null),
     assert(textAlign != null),
     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 != null),
     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(autofocus != null),
     assert(rendererIgnoresPointer != null),
     assert(scrollPadding != null),
     assert(dragStartBehavior != null),
     assert(toolbarOptions != null),
     assert(clipBehavior != null),
     _strutStyle = strutStyle,
     keyboardType = keyboardType ?? _inferKeyboardType(autofillHints: autofillHints, maxLines: maxLines),
     inputFormatters = maxLines == 1
         ? <TextInputFormatter>[
             FilteringTextInputFormatter.singleLineFormatter,
             ...inputFormatters ?? const Iterable<TextInputFormatter>.empty(),
           ]
         : inputFormatters,
     showCursor = showCursor ?? !readOnly,
     super(key: key);