textOrNull function
Implementation
Widget? textOrNull(final txt, {TextAlign? alignment, TextStyle? style, Color? color, bool wrap = true, int? maxLines}) {
if (txt is Widget) return txt;
if (txt == null) return null;
final text = "$txt";
var _style = style ?? TextStyle();
_style = _style.copyWith(color: color);
return text.isNullOrBlank
? null
: wrap == false
? maxLines != null && maxLines > 1
? Text(
text,
maxLines: maxLines,
style: _style,
textAlign: alignment,
softWrap: false,
overflow: TextOverflow.fade,
)
: SingleLineText(
text,
style: _style,
alignment: alignment,
)
: Text(
text,
maxLines: maxLines,
style: _style,
textAlign: alignment,
softWrap: true,
overflow: TextOverflow.fade,
);
}