toTextSpan method

TextSpan toTextSpan({
  1. TextStyle? style,
  2. TextStyle regularTextStyle = const TextStyle(fontWeight: FontWeight.normal),
  3. TextStyle highlightedTextStyle = const TextStyle(fontWeight: FontWeight.bold),
  4. GestureRecognizer? recognizer,
  5. MouseCursor? mouseCursor,
  6. PointerEnterEventListener? onEnter,
  7. PointerExitEventListener? onExit,
  8. String? semanticsLabel,
  9. Locale? locale,
  10. bool? spellOut,
})

Converts HighlightedString to TextSpan. Applies regularTextStyle and highlightedTextStyle styles to to non-highlighted and highlighted sub-spans accordingly.

Example

Text.rich(
  hit.getHighlightedString('title').toTextSpan(),
);

Implementation

TextSpan toTextSpan({
  TextStyle? style,
  TextStyle regularTextStyle = const TextStyle(fontWeight: FontWeight.normal),
  TextStyle highlightedTextStyle =
      const TextStyle(fontWeight: FontWeight.bold),
  GestureRecognizer? recognizer,
  MouseCursor? mouseCursor,
  PointerEnterEventListener? onEnter,
  PointerExitEventListener? onExit,
  String? semanticsLabel,
  Locale? locale,
  bool? spellOut,
}) =>
    TextSpan(
      style: style,
      children: toInlineSpans(
        regularTextStyle: regularTextStyle,
        highlightedTextStyle: highlightedTextStyle,
      ),
      recognizer: recognizer,
      mouseCursor: mouseCursor,
      onEnter: onEnter,
      onExit: onExit,
      semanticsLabel: semanticsLabel,
      locale: locale,
      spellOut: spellOut,
    );