intColor static method

int intColor(
  1. String? colorString
)

Implementation

static int intColor(String? colorString) {
  if (colorString?.isEmpty ?? true) {
    throw ArgumentError('Unknown color');
  }
  if (colorString![0] == '#') {
    int? color = int.tryParse(colorString.substring(1), radix: 16);
    if (colorString.length == 7 && color != null) {
      // Set the alpha value
      color |= 0x00000000ff000000;
    } else if (colorString.length != 9) {
      throw ArgumentError('Unknown color');
    }
    return color!;
  } else {
    return intColor('#$colorString');
  }
}