hexToColor static method

Color hexToColor(
  1. String hexString
)

Implementation

static Color hexToColor(String hexString) {
  final buffer = StringBuffer();
  if (hexString.length == 6 || hexString.length == 7) {
    buffer.write('ff'); // Adds 'ff' for opacity if alpha is missing
  }
  buffer.write(hexString.replaceFirst('#', '')); // Removes the # if present
  return Color(int.parse(buffer.toString(), radix: 16));
}