parseColor2String static method

String? parseColor2String(
  1. Color? color
)

将颜色转为字符串

Implementation

static String? parseColor2String(Color? color) {
  if (color == null) {
    return null;
  }
  var aa = color.alpha.toRadixString(16);
  if (aa.length == 1) {
    aa = "0$aa";
  }
  var rr = color.red.toRadixString(16);
  if (rr.length == 1) {
    rr = "0$rr";
  }
  var gg = color.green.toRadixString(16);
  if (gg.length == 1) {
    gg = "0$gg";
  }
  var bb = color.blue.toRadixString(16);
  if (bb.length == 1) {
    bb = "0$bb";
  }
  return "#$aa$rr$gg$bb";
}