hex2rgb function

List<num> hex2rgb (
  1. String hex
)

returns a rgb array

Implementation

List<num> hex2rgb(String hex) {
  var hs = hex[0] == '#' ? hex.substring(1) : hex;
  return [
    int.parse(hs[0] + hs[1], radix: 16),
    int.parse(hs[2] + hs[3], radix: 16),
    int.parse(hs[4] + hs[5], radix: 16)
  ];
}