hexColor static method

String hexColor({
  1. bool withAlpha = false,
})

Generates a random color as a hex string, e.g. '#AABBCC'.

Implementation

static String hexColor({bool withAlpha = false}) {
  final rand = math.Random();
  int value = withAlpha ? rand.nextInt(0x100000000) : rand.nextInt(0x1000000);
  return withAlpha
      ? '#${value.toRadixString(16).padLeft(8, '0').toUpperCase()}'
      : '#${value.toRadixString(16).padLeft(6, '0').toUpperCase()}';
}