RenderEditable constructor

RenderEditable({TextSpan text, @required TextDirection textDirection, TextAlign textAlign: TextAlign.start, Color cursorColor, Color backgroundCursorColor, ValueNotifier<bool> showCursor, bool hasFocus, @required LayerLink startHandleLayerLink, @required LayerLink endHandleLayerLink, int maxLines: 1, int minLines, bool expands: false, StrutStyle strutStyle, Color selectionColor, double textScaleFactor: 1.0, TextSelection selection, @required ViewportOffset offset, SelectionChangedHandler onSelectionChanged, CaretChangedHandler onCaretChanged, bool ignorePointer: false, bool readOnly: false, bool forceLine: true, TextWidthBasis textWidthBasis: TextWidthBasis.parent, bool obscureText: false, Locale locale, double cursorWidth: 1.0, Radius cursorRadius, bool paintCursorAboveText: false, Offset cursorOffset, double devicePixelRatio: 1.0, bool enableInteractiveSelection, EdgeInsets floatingCursorAddedMargin: const EdgeInsets.fromLTRB(4, 4, 4, 5), @required TextSelectionDelegate textSelectionDelegate })

Creates a render object that implements the visual aspects of a text field.

The textAlign argument must not be null. It defaults to TextAlign.start.

The textDirection argument must not be null.

If showCursor is not specified, then it defaults to hiding the cursor.

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

The offset is required and must not be null. You can use new ViewportOffset.zero if you have no need for scrolling.

Implementation

RenderEditable({
  TextSpan text,
  @required TextDirection textDirection,
  TextAlign textAlign = TextAlign.start,
  Color cursorColor,
  Color backgroundCursorColor,
  ValueNotifier<bool> showCursor,
  bool hasFocus,
  @required LayerLink startHandleLayerLink,
  @required LayerLink endHandleLayerLink,
  int maxLines = 1,
  int minLines,
  bool expands = false,
  StrutStyle strutStyle,
  Color selectionColor,
  double textScaleFactor = 1.0,
  TextSelection selection,
  @required ViewportOffset offset,
  this.onSelectionChanged,
  this.onCaretChanged,
  this.ignorePointer = false,
  bool readOnly = false,
  bool forceLine = true,
  TextWidthBasis textWidthBasis = TextWidthBasis.parent,
  bool obscureText = false,
  Locale locale,
  double cursorWidth = 1.0,
  Radius cursorRadius,
  bool paintCursorAboveText = false,
  Offset cursorOffset,
  double devicePixelRatio = 1.0,
  bool enableInteractiveSelection,
  EdgeInsets floatingCursorAddedMargin = const EdgeInsets.fromLTRB(4, 4, 4, 5),
  @required this.textSelectionDelegate,
}) : assert(textAlign != null),
     assert(textDirection != null, 'RenderEditable created without a textDirection.'),
     assert(maxLines == null || maxLines > 0),
     assert(minLines == null || minLines > 0),
     assert(startHandleLayerLink != null),
     assert(endHandleLayerLink != null),
     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(textScaleFactor != null),
     assert(offset != null),
     assert(ignorePointer != null),
     assert(textWidthBasis != null),
     assert(paintCursorAboveText != null),
     assert(obscureText != null),
     assert(textSelectionDelegate != null),
     assert(cursorWidth != null && cursorWidth >= 0.0),
     assert(readOnly != null),
     assert(forceLine != null),
     assert(devicePixelRatio != null),
     _textPainter = TextPainter(
       text: text,
       textAlign: textAlign,
       textDirection: textDirection,
       textScaleFactor: textScaleFactor,
       locale: locale,
       strutStyle: strutStyle,
       textWidthBasis: textWidthBasis,
     ),
     _cursorColor = cursorColor,
     _backgroundCursorColor = backgroundCursorColor,
     _showCursor = showCursor ?? ValueNotifier<bool>(false),
     _maxLines = maxLines,
     _minLines = minLines,
     _expands = expands,
     _selectionColor = selectionColor,
     _selection = selection,
     _offset = offset,
     _cursorWidth = cursorWidth,
     _cursorRadius = cursorRadius,
     _paintCursorOnTop = paintCursorAboveText,
     _cursorOffset = cursorOffset,
     _floatingCursorAddedMargin = floatingCursorAddedMargin,
     _enableInteractiveSelection = enableInteractiveSelection,
     _devicePixelRatio = devicePixelRatio,
     _startHandleLayerLink = startHandleLayerLink,
     _endHandleLayerLink = endHandleLayerLink,
     _obscureText = obscureText,
     _readOnly = readOnly,
     _forceLine = forceLine {
  assert(_showCursor != null);
  assert(!_showCursor.value || cursorColor != null);
  this.hasFocus = hasFocus ?? false;
  _tap = TapGestureRecognizer(debugOwner: this)
    ..onTapDown = _handleTapDown
    ..onTap = _handleTap;
  _longPress = LongPressGestureRecognizer(debugOwner: this)
    ..onLongPress = _handleLongPress;
}