BidiSelectableText.rich constructor

const BidiSelectableText.rich(
  1. TextSpan textSpan, {
  2. Key? key,
  3. FocusNode? focusNode,
  4. TextStyle? style,
  5. StrutStyle? strutStyle,
  6. TextAlign? textAlign,
  7. TextScaler? textScaler,
  8. bool showCursor = false,
  9. bool autofocus = false,
  10. int? minLines,
  11. int? maxLines,
  12. double cursorWidth = 2.0,
  13. double? cursorHeight,
  14. Radius? cursorRadius,
  15. Color? cursorColor,
  16. BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
  17. BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
  18. bool enableInteractiveSelection = true,
  19. TextSelectionControls? selectionControls,
  20. GestureTapCallback? onTap,
  21. ScrollPhysics? scrollPhysics,
  22. String? semanticsLabel,
  23. TextHeightBehavior? textHeightBehavior,
  24. TextWidthBasis? textWidthBasis,
  25. SelectionChangedCallback? onSelectionChanged,
  26. EditableTextContextMenuBuilder? contextMenuBuilder,
  27. TextMagnifierConfiguration? magnifierConfiguration,
  28. int? sampleLength = 50,
})

Creates a BidiSelectableText widget with a TextSpan — a drop-in replacement for SelectableText.rich.

Direction is detected by extracting all text from the TextSpan tree (nested TextSpan children are traversed; WidgetSpan nodes are ignored).

Example:

BidiSelectableText.rich(
  TextSpan(children: [
    TextSpan(text: 'مرحبا '),
    TextSpan(text: 'world', style: TextStyle(color: Colors.blue)),
  ]),
)

Implementation

const BidiSelectableText.rich(
  TextSpan this.textSpan, {
  super.key,
  this.focusNode,
  this.style,
  this.strutStyle,
  this.textAlign,
  this.textScaler,
  this.showCursor = false,
  this.autofocus = false,
  this.minLines,
  this.maxLines,
  this.cursorWidth = 2.0,
  this.cursorHeight,
  this.cursorRadius,
  this.cursorColor,
  this.selectionHeightStyle = ui.BoxHeightStyle.tight,
  this.selectionWidthStyle = ui.BoxWidthStyle.tight,
  this.enableInteractiveSelection = true,
  this.selectionControls,
  this.onTap,
  this.scrollPhysics,
  this.semanticsLabel,
  this.textHeightBehavior,
  this.textWidthBasis,
  this.onSelectionChanged,
  this.contextMenuBuilder,
  this.magnifierConfiguration,
  this.sampleLength = 50,
}) : data = null;