buildTextSpanChildren function

List<InlineSpan>? buildTextSpanChildren(
  1. List<LinkifyElement> elements, {
  2. TextStyle? style,
  3. TextStyle? linkStyle,
  4. LinkCallback? onOpen,
  5. bool useMouseRegion = false,
})

Raw TextSpan builder for more control on the RichText

Implementation

List<InlineSpan>? buildTextSpanChildren(
  List<LinkifyElement> elements, {
  TextStyle? style,
  TextStyle? linkStyle,
  LinkCallback? onOpen,
  bool useMouseRegion = false,
}) =>
    [
      for (var element in elements)
        if (element is LinkableElement)
          TextSpan(
            text: element.text,
            style: linkStyle,
            recognizer: onOpen != null
                ? (TapGestureRecognizer()..onTap = () => onOpen(element))
                : null,
            mouseCursor: useMouseRegion ? SystemMouseCursors.click : null,
          )
        else
          TextSpan(
            text: element.text,
            style: style,
          ),
    ];