toRGBAInt method

int toRGBAInt()

Implementation

int toRGBAInt() {
  final match = RegExp(
    r'^rgba\(([\d.]+),\s*([\d.]+),\s*([\d.]+),\s*([\d.]+)\)$',
  ).firstMatch(this);
  if (match == null) {
    return 0;
  }
  final red = double.parse(match.group(1)!).round();
  final green = double.parse(match.group(2)!).round();
  final blue = double.parse(match.group(3)!).round();
  final alpha = (double.parse(match.group(4)!) * 255).round();
  return Color.fromARGB(alpha, red, green, blue).value;
}