addTextWithLink method

RichTextGenerator addTextWithLink(
  1. String text, {
  2. String? url,
  3. TextStyle? textStyle,
  4. Color? linkColor,
  5. double? fontSize,
  6. FontWeight? fontWeight,
  7. HyperLinkCallback? richTextLinkClick,
})

添加超链接部分的文案 text 显示的文案 url 超链接的 url textStyle 文案的样式 linkColor 超链接的颜色 fontSize 显示大小 fontWeight 字体粗细 richTextLinkClick 超链接点击的回调

Implementation

RichTextGenerator addTextWithLink(
  String text, {
  String? url,
  TextStyle? textStyle,
  Color? linkColor,
  double? fontSize,
  FontWeight? fontWeight,
  HyperLinkCallback? richTextLinkClick,
}) {
  _spanList.add(
    TextSpan(
      style: textStyle ??
          TextStyle(
            color: linkColor ??
                BaseThemeConfig.instance
                    .getConfig()
                    .commonConfig
                    .brandPrimary,
            fontWeight: fontWeight ?? FontWeight.normal,
            fontSize: fontSize ?? 16,
          ),
      text: text,
      recognizer: TapGestureRecognizer()
        ..onTap = () {
          if (richTextLinkClick != null) {
            richTextLinkClick(text, url);
          }
        },
    ),
  );
  return this;
}