buildText function

Widget buildText(
  1. String text, {
  2. TextStyle? textStyle,
  3. int? maxLines,
  4. double fontSize = 14,
  5. Color? color,
  6. bool hideIfEmpty = false,
  7. EdgeInsets? margin,
  8. TextDecoration? textDecoration,
  9. TextAlign? textAlign,
  10. FontWeight? fontWeight,
  11. 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;

}