SpanDefinition constructor

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

Creates a SpanDefinition that defines parsing rules, appearance and actions, and builds the InlineSpan to replace certain portions of text with.

The builder function receives the entire matched string and a list of strings that have matched the fragments enclosed in parentheses within the match pattern. Use the function to return an object of InlineSpan or its subtype (e.g. WidgetSpan) to display it instead of the matched string.

When this definition type is used, the InlineSpan created by the builder callback is not shown until parsing completes and spots which parts in the original text need to be replaced with the span, so that the raw text is not shown as is while waiting. Exceptionally, this behaviour is not applied if CustomText.preventBlocking is enabled.

See also the document of TextDefinition, which has most of other properties in common.

Implementation

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