MongolRenderEditable constructor

MongolRenderEditable({
  1. TextSpan? text,
  2. MongolTextAlign textAlign = MongolTextAlign.top,
  3. Color? cursorColor,
  4. ValueNotifier<bool>? showCursor,
  5. bool? hasFocus,
  6. required LayerLink startHandleLayerLink,
  7. required LayerLink endHandleLayerLink,
  8. int? maxLines = 1,
  9. int? minLines,
  10. bool expands = false,
  11. Color? selectionColor,
  12. double textScaleFactor = 1.0,
  13. TextSelection? selection,
  14. required ViewportOffset offset,
  15. bool ignorePointer = false,
  16. bool readOnly = false,
  17. bool forceLine = true,
  18. String obscuringCharacter = '•',
  19. bool obscureText = false,
  20. double? cursorWidth,
  21. double cursorHeight = 1.0,
  22. Radius? cursorRadius,
  23. Offset cursorOffset = Offset.zero,
  24. double devicePixelRatio = 1.0,
  25. bool? enableInteractiveSelection,
  26. Clip clipBehavior = Clip.hardEdge,
  27. required TextSelectionDelegate textSelectionDelegate,
  28. MongolRenderEditablePainter? painter,
  29. MongolRenderEditablePainter? foregroundPainter,
})

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

The textAlign argument must not be null. It defaults to MongolTextAlign.top.

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 ViewportOffset.zero if you have no need for scrolling.

Implementation

MongolRenderEditable({
  TextSpan? text,
  MongolTextAlign textAlign = MongolTextAlign.top,
  Color? cursorColor,
  ValueNotifier<bool>? showCursor,
  bool? hasFocus,
  required LayerLink startHandleLayerLink,
  required LayerLink endHandleLayerLink,
  int? maxLines = 1,
  int? minLines,
  bool expands = false,
  Color? selectionColor,
  double textScaleFactor = 1.0,
  TextSelection? selection,
  required ViewportOffset offset,
  this.ignorePointer = false,
  bool readOnly = false,
  bool forceLine = true,
  String obscuringCharacter = '•',
  bool obscureText = false,
  double? cursorWidth,
  double cursorHeight = 1.0,
  Radius? cursorRadius,
  Offset cursorOffset = Offset.zero,
  double devicePixelRatio = 1.0,
  bool? enableInteractiveSelection,
  Clip clipBehavior = Clip.hardEdge,
  required this.textSelectionDelegate,
  MongolRenderEditablePainter? painter,
  MongolRenderEditablePainter? foregroundPainter,
})  : 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(obscuringCharacter.characters.length == 1),
      assert(cursorWidth == null || cursorWidth >= 0.0),
      assert(cursorHeight >= 0.0),
      _textPainter = MongolTextPainter(
        text: text,
        textAlign: textAlign,
        textScaleFactor: textScaleFactor,
        maxLines: maxLines == 1 ? 1 : null,
      ),
      _showCursor = showCursor ?? ValueNotifier<bool>(false),
      _maxLines = maxLines,
      _minLines = minLines,
      _expands = expands,
      _selection = selection,
      _offset = offset,
      _cursorWidth = cursorWidth,
      _cursorHeight = cursorHeight,
      _enableInteractiveSelection = enableInteractiveSelection,
      _devicePixelRatio = devicePixelRatio,
      _startHandleLayerLink = startHandleLayerLink,
      _endHandleLayerLink = endHandleLayerLink,
      _obscuringCharacter = obscuringCharacter,
      _obscureText = obscureText,
      _readOnly = readOnly,
      _forceLine = forceLine,
      _clipBehavior = clipBehavior {
  assert(!_showCursor.value || cursorColor != null);
  this.hasFocus = hasFocus ?? false;

  _selectionPainter.highlightColor = selectionColor;
  _selectionPainter.highlightedRange = selection;

  _caretPainter.caretColor = cursorColor;
  _caretPainter.cursorRadius = cursorRadius;
  _caretPainter.cursorOffset = cursorOffset;

  _updateForegroundPainter(foregroundPainter);
  _updatePainter(painter);
}