TextDefinition constructor

const TextDefinition({
  1. required TextMatcher matcher,
  2. Key? rebuildKey,
  3. TextStyle? matchStyle,
  4. TextStyle? tapStyle,
  5. TextStyle? hoverStyle,
  6. GestureCallback? onTap,
  7. GestureCallback? onLongPress,
  8. GestureCallback? onGesture,
  9. MouseCursor? mouseCursor,
})

Creates a TextDefinition that defines rules for parsing, appearance and actions for CustomText, CustomTextEditingController and CustomSpanBuilder.

The strings that have matched the pattern defined in matcher are styled according to matchStyle, tapStyle and hoverStyle while not pressed, being pressed, and being hovered, respectively.

onTap and onLongPress are handler functions called when a TextSpan is tapped and long-pressed. onGesture is a handler function called when other gesture events happen. A GestureDetails object containing details on the element and the event (kind, text, tap position, etc) is passed in to the functions.

mouseCursor is a mouse cursor type used while the mouse hovers over a matching text element. Note that even if this is omitted, SystemMouseCursors.click is automatically used if onTap or onLongPress is specified.

Also note that most properties are ignored in CustomSpanBuilder. See its document for details.

Implementation

const TextDefinition({
  required super.matcher,
  super.rebuildKey,
  super.matchStyle,
  super.tapStyle,
  super.hoverStyle,
  super.onTap,
  super.onLongPress,
  super.onGesture,
  super.mouseCursor,
});