RenderEditable constructor
- InlineSpan? 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,
- @Deprecated('Use textScaler instead. ' 'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. ' 'This feature was deprecated after v3.12.0-2.0.pre.') double textScaleFactor = 1.0,
- TextScaler textScaler = TextScaler.noScaling,
- TextSelection? selection,
- required ViewportOffset offset,
- bool ignorePointer = false,
- bool readOnly = false,
- bool forceLine = true,
- TextHeightBehavior? textHeightBehavior,
- TextWidthBasis textWidthBasis = TextWidthBasis.parent,
- String obscuringCharacter = '•',
- bool obscureText = false,
- Locale? locale,
- double cursorWidth = 1.0,
- double? cursorHeight,
- Radius? cursorRadius,
- bool paintCursorAboveText = false,
- Offset cursorOffset = Offset.zero,
- double devicePixelRatio = 1.0,
- BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
- BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
- bool? enableInteractiveSelection,
- EdgeInsets floatingCursorAddedMargin = const EdgeInsets.fromLTRB(4, 4, 4, 5),
- TextRange? promptRectRange,
- Color? promptRectColor,
- Clip clipBehavior = Clip.hardEdge,
- required TextSelectionDelegate textSelectionDelegate,
- RenderEditablePainter? painter,
- RenderEditablePainter? foregroundPainter,
- List<
RenderBox> ? children,
Creates a render object that implements the visual aspects of a text field.
The textAlign
argument defaults to TextAlign.start.
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.
Use ViewportOffset.zero for the offset
if there is no need for
scrolling.
Implementation
RenderEditable({
InlineSpan? 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,
@Deprecated(
'Use textScaler instead. '
'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. '
'This feature was deprecated after v3.12.0-2.0.pre.',
)
double textScaleFactor = 1.0,
TextScaler textScaler = TextScaler.noScaling,
TextSelection? selection,
required ViewportOffset offset,
this.ignorePointer = false,
bool readOnly = false,
bool forceLine = true,
TextHeightBehavior? textHeightBehavior,
TextWidthBasis textWidthBasis = TextWidthBasis.parent,
String obscuringCharacter = '•',
bool obscureText = false,
Locale? locale,
double cursorWidth = 1.0,
double? cursorHeight,
Radius? cursorRadius,
bool paintCursorAboveText = false,
Offset cursorOffset = Offset.zero,
double devicePixelRatio = 1.0,
ui.BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
ui.BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
bool? enableInteractiveSelection,
this.floatingCursorAddedMargin = const EdgeInsets.fromLTRB(4, 4, 4, 5),
TextRange? promptRectRange,
Color? promptRectColor,
Clip clipBehavior = Clip.hardEdge,
required this.textSelectionDelegate,
RenderEditablePainter? painter,
RenderEditablePainter? foregroundPainter,
List<RenderBox>? children,
}) : 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(
identical(textScaler, TextScaler.noScaling) || textScaleFactor == 1.0,
'textScaleFactor is deprecated and cannot be specified when textScaler is specified.',
),
assert(obscuringCharacter.characters.length == 1),
assert(cursorWidth >= 0.0),
assert(cursorHeight == null || cursorHeight >= 0.0),
_textPainter = TextPainter(
text: text,
textAlign: textAlign,
textDirection: textDirection,
textScaler: textScaler == TextScaler.noScaling ? TextScaler.linear(textScaleFactor) : textScaler,
locale: locale,
maxLines: maxLines == 1 ? 1 : null,
strutStyle: strutStyle,
textHeightBehavior: textHeightBehavior,
textWidthBasis: textWidthBasis,
),
_showCursor = showCursor ?? ValueNotifier<bool>(false),
_maxLines = maxLines,
_minLines = minLines,
_expands = expands,
_selection = selection,
_offset = offset,
_cursorWidth = cursorWidth,
_cursorHeight = cursorHeight,
_paintCursorOnTop = paintCursorAboveText,
_enableInteractiveSelection = enableInteractiveSelection,
_devicePixelRatio = devicePixelRatio,
_startHandleLayerLink = startHandleLayerLink,
_endHandleLayerLink = endHandleLayerLink,
_obscuringCharacter = obscuringCharacter,
_obscureText = obscureText,
_readOnly = readOnly,
_forceLine = forceLine,
_clipBehavior = clipBehavior,
_hasFocus = hasFocus ?? false,
_disposeShowCursor = showCursor == null {
assert(!_showCursor.value || cursorColor != null);
_selectionPainter.highlightColor = selectionColor;
_selectionPainter.highlightedRange = selection;
_selectionPainter.selectionHeightStyle = selectionHeightStyle;
_selectionPainter.selectionWidthStyle = selectionWidthStyle;
_autocorrectHighlightPainter.highlightColor = promptRectColor;
_autocorrectHighlightPainter.highlightedRange = promptRectRange;
_caretPainter.caretColor = cursorColor;
_caretPainter.cursorRadius = cursorRadius;
_caretPainter.cursorOffset = cursorOffset;
_caretPainter.backgroundCursorColor = backgroundCursorColor;
_updateForegroundPainter(foregroundPainter);
_updatePainter(painter);
addAll(children);
}