DiscordColor.fromHexString constructor

DiscordColor.fromHexString(
  1. String hexStr
)

Construct color from hex String. Leading # will be ignored in process.

Implementation

factory DiscordColor.fromHexString(String hexStr) {
  if (hexStr.isEmpty) {
    throw ArgumentError("Hex color String cannot be empty");
  }

  if (hexStr.startsWith("#")) {
    hexStr = hexStr.substring(1);
  }

  return DiscordColor.fromInt(int.parse(hexStr, radix: 16));
}