create method

TextPainter create(
  1. TextPainter painter,
  2. String text,
  3. Color color,
  4. double fontSize,
  5. {String fontFamily,
  6. FontWeight fontWeight = FontWeight.w400}
)

Implementation

static TextPainter create(
    TextPainter painter, String text, Color color, double fontSize,
    {String fontFamily, FontWeight fontWeight = FontWeight.w400}) {
  if (painter == null) {
    return _create(text, color, fontSize,
        fontFamily: fontFamily, fontWeight: fontWeight);
  }

  if (painter.text != null && (painter.text is TextSpan)) {
    var preText = painter.text.text;
    var preColor = painter.text.style.color;
    preColor = preColor == null ? ColorUtils.BLACK : preColor;
    var preFontSize = painter.text.style.fontSize;
    preFontSize =
        preFontSize == null ? Utils.convertDpToPixel(13) : preFontSize;
    return _create(
        text == null ? preText : text,
        color == null ? preColor : color,
        fontSize == null ? preFontSize : fontSize,
        fontFamily: fontFamily,
        fontWeight: fontWeight);
  } else {
    return _create(text, color, fontSize,
        fontFamily: fontFamily, fontWeight: fontWeight);
  }
}