customTextSpan function

TextSpan customTextSpan(
  1. String message,
  2. String prevValue,
  3. TextStyle? normalStyle,
  4. TextStyle? underlineStyle,
)

Implementation

TextSpan customTextSpan(String message, String prevValue,
    TextStyle? normalStyle, TextStyle? underlineStyle) {
  return TextSpan(
    children: message.split(" ").map((e) {
      if (isCountryCode(e)) {
        prevValue = e;
      } else if (prevValue != "" && spannableTextType(e) == "mobile") {
        e = "$prevValue $e";
        prevValue = "";
      }
      return TextSpan(
          text: "$e ",
          style: spannableTextType(e) == "text" ? normalStyle : underlineStyle,
          recognizer: TapGestureRecognizer()
            ..onTap = () {
              onTapForSpanText(e);
            });
    }).toList(),
  );
}