customTextSpan function

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

Implementation

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