regular method

Widget regular(
  1. BuildContext context,
  2. String? text, {
  3. int? maxLines,
  4. TextAlign? textAlign,
  5. bool? bold = false,
  6. Color? color,
  7. double? height,
  8. String? highlightText,
  9. TextDecoration? decoration,
})

Implementation

Widget regular(BuildContext context, String? text,
    {int? maxLines,
    TextAlign? textAlign,
    bool? bold = false,
    Color? color,
    double? height,
    String? highlightText,
    TextDecoration? decoration}) {
  if (highlightText != null) {
    TextStyle selectedTextStyle = TextStyle(
      fontSize: DUI.text.regularText,
      height: DUI.text.textHeight,
      fontWeight: DUI.text.boldWeight,
      fontFamily: Theme.of(context).textTheme.bodyMedium!.fontFamily,
      color: Theme.of(context).textTheme.bodyMedium!.color,
    );
    TextStyle unselectedTextStyle = TextStyle(
      fontSize: DUI.text.regularText,
      height: DUI.text.textHeight,
      fontWeight: DUI.text.semiBoldWeight,
      fontFamily: Theme.of(context).textTheme.bodyMedium!.fontFamily,
      color: highlightText.isNotEmpty
          ? Theme.of(context).textTheme.bodyMedium!.color!.withOpacity(0.85)
          : Theme.of(context).textTheme.bodyMedium!.color,
    );

    return SubstringHighlight(
      text: text ?? '',
      term: highlightText,
      textStyle: unselectedTextStyle,
      textStyleHighlight: selectedTextStyle,
    );
  }

  return Text(
    text ?? '',
    textAlign: textAlign ?? TextAlign.start,
    maxLines: maxLines,
    overflow: maxLines != null ? TextOverflow.ellipsis : null,
    style: regularTextStyle(context,
        bold: bold, color: color, height: height, decoration: decoration),
  );
}