getTextSpan method

dynamic getTextSpan(
  1. Color labelColor,
  2. dynamic param,
  3. dynamic showValue
)

Implementation

getTextSpan(Color labelColor, param, showValue) {
  myLogAll('getTextSpan');
  showValue = '$showValue';
  var originalValue = (param[gNeedi10n] ?? true)
      ? getSCurrent(param[gOriginalValue])
      : param[gOriginalValue];
  List<TextSpan> txtSpanChildren = [];

  var s0 = originalValue;

  if ((param[gSearch] ?? '') != '' &&
      originalValue.toString().contains(param[gSearch])) {
    List sA = originalValue.split(param[gSearch]);
    s0 = sA[0];
    for (int i = 1; i < sA.length; i++) {
      txtSpanChildren.add(TextSpan(
          text: param[gSearch],
          style: TextStyle(
            color: labelColor,
            decoration: param[gTextDecoration],
            fontSize: getFontSize(param) ?? defaultFontSize,
            backgroundColor: searchColor,
          )));
      txtSpanChildren.add(TextSpan(
          text: sA[i],
          style: TextStyle(
            color: labelColor,
            decoration: param[gTextDecoration],
            fontSize: getFontSize(param) ?? defaultFontSize,
          )));
    }
  }
  txtSpanChildren.add(TextSpan(
      text: ' -> \r\n',
      style: TextStyle(
        fontStyle: FontStyle.italic,
        color: labelColor,
        fontSize: getFontSize(param) ?? defaultFontSize,
      )));

  if ((param[gSearch] ?? '') != '' &&
      originalValue.toString().contains(param[gSearch])) {
    List sA = showValue.split(param[gSearch]);
    txtSpanChildren.add(TextSpan(
        text: sA[0],
        style: TextStyle(
          fontWeight: FontWeight.bold,
          color: param[gColorLabel] ?? labelColor,
          fontSize: getFontSize(param) ?? defaultFontSize,
        )));
    for (int i = 1; i < sA.length; i++) {
      txtSpanChildren.add(TextSpan(
          text: param[gSearch],
          style: TextStyle(
            color: param[gColorLabel] ?? labelColor,
            fontWeight: FontWeight.bold,
            fontSize: getFontSize(param) ?? defaultFontSize,
            backgroundColor: searchColor,
          )));
      txtSpanChildren.add(TextSpan(
          text: sA[i],
          style: TextStyle(
            fontWeight: FontWeight.bold,
            color: param[gColorLabel] ?? labelColor,
            fontSize: getFontSize(param) ?? defaultFontSize,
          )));
    }
  } else {
    txtSpanChildren.add(TextSpan(
        text: showValue,
        style: TextStyle(
          fontWeight: FontWeight.bold,
          color: param[gColorLabel] ?? labelColor,
          fontSize: getFontSize(param) ?? defaultFontSize,
        )));
  }

  return TextSpan(
      text: s0,
      style: TextStyle(
        color: labelColor,
        decoration: param[gTextDecoration],
        fontSize: getFontSize(param) ?? defaultFontSize,
      ),
      children: txtSpanChildren);
}