SelectableText constructor
const
SelectableText(
- String data, {
- Key? key,
- FocusNode? focusNode,
- TextStyle? style,
- StrutStyle? strutStyle,
- TextAlign? textAlign,
- TextDirection? textDirection,
- TextScaler? textScaler,
- bool showCursor = false,
- bool autofocus = false,
- int? minLines,
- int? maxLines,
- double cursorWidth = 2.0,
- double? cursorHeight,
- Radius? cursorRadius,
- Color? cursorColor,
- BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
- BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- bool enableInteractiveSelection = true,
- TextSelectionControls? selectionControls,
- GestureTapCallback? onTap,
- ScrollPhysics? scrollPhysics,
- String? semanticsLabel,
- TextHeightBehavior? textHeightBehavior,
- TextWidthBasis? textWidthBasis,
- SelectionChangedCallback? onSelectionChanged,
- bool useNativeContextMenu = false,
- EditableTextContextMenuBuilder? contextMenuBuilder = _defaultContextMenuBuilder,
- TextMagnifierConfiguration? magnifierConfiguration,
Creates selectable text from a plain string.
The data parameter is the text to display. All other parameters
are optional and control various aspects of text rendering and selection.
Parameters:
data: The text string to display (required)focusNode: Focus node for keyboard interactionstyle: Text style for the contentstrutStyle: Strut style for line heighttextAlign: How to align text horizontallytextDirection: Text direction (LTR or RTL)textScaler: Text scaling factorshowCursor: Whether to show the cursor (defaults tofalse)autofocus: Auto-focus on mount (defaults tofalse)minLines: Minimum number of lines to occupymaxLines: Maximum number of lines before scrollingcursorWidth: Width of cursor (defaults to 2.0)cursorHeight: Height of cursor (null = line height)cursorRadius: Cursor corner radiuscursorColor: Cursor colorselectionHeightStyle: Selection box height behaviorselectionWidthStyle: Selection box width behaviordragStartBehavior: When to start drag gesturesenableInteractiveSelection: Enable selection (defaults totrue)selectionControls: Custom selection toolbar controlsonTap: Callback when text is tappedscrollPhysics: Scroll behavior physicssemanticsLabel: Semantic label for accessibilitytextHeightBehavior: How to handle line heightstextWidthBasis: Basis for measuring text widthonSelectionChanged: Callback when selection changesuseNativeContextMenu: Use platform context menu (defaults tofalse)contextMenuBuilder: Custom context menu buildermagnifierConfiguration: Text magnifier configuration
Implementation
const SelectableText(
String this.data, {
super.key,
this.focusNode,
this.style,
this.strutStyle,
this.textAlign,
this.textDirection,
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.dragStartBehavior = DragStartBehavior.start,
this.enableInteractiveSelection = true,
this.selectionControls,
this.onTap,
this.scrollPhysics,
this.semanticsLabel,
this.textHeightBehavior,
this.textWidthBasis,
this.onSelectionChanged,
this.useNativeContextMenu = false,
this.contextMenuBuilder = _defaultContextMenuBuilder,
this.magnifierConfiguration,
}) : assert(maxLines == null || maxLines > 0),
assert(minLines == null || minLines > 0),
assert(
(maxLines == null) || (minLines == null) || (maxLines >= minLines),
"minLines can't be greater than maxLines",
),
textSpan = null;