buildText function
Widget
buildText(
- String text, {
- TextStyle? textStyle,
- int? maxLines,
- double fontSize = 14,
- Color? color,
- bool hideIfEmpty = false,
- EdgeInsets? margin,
- TextDecoration? textDecoration,
- TextAlign? textAlign,
- FontWeight? fontWeight,
- TextOverflow? overflow,
Implementation
Widget buildText(String text, {TextStyle? textStyle,
int? maxLines,
double fontSize = 14,
Color? color,
bool hideIfEmpty = false,
EdgeInsets? margin,
TextDecoration? textDecoration,
TextAlign? textAlign,
FontWeight? fontWeight,
TextOverflow? overflow
}){
Widget child = Text(
text,
maxLines: maxLines,
overflow: overflow,
textAlign: textAlign,
style: textStyle??TextStyle(
decoration: textDecoration,
fontSize: getSp(fontSize),
fontWeight: fontWeight,
color: color
),
);
if(margin != null){
child = buildSmartContainer(
visible: hideIfEmpty,
margin: margin,
child: child,
);
}
if(hideIfEmpty){
child = Visibility(
visible: ObjectUtil.isNotEmpty(text) && ObjectUtil.isNotEmpty(text.trim()),
child: child,
);
}
return child;
}