randomColor static method

int randomColor()

Generates a random integer that represents a Hex color. 生成一个表示十六进制颜色的随机整数

Implementation

static int randomColor() {
  var hex = "0xFF";
  Random random = Random();
  for (int i = 0; i < 3; i++) {
    hex += random.nextInt(255).toRadixString(16).padLeft(2, '0');
  }
  return int.parse(hex);
}