flutterdart

How to convert Color to a list of RGB values in Dart & Flutter?


I would like to be able to take a Color and convert it into a List<int> so like [0,255,255].

How do I do that?


Solution

  • List<int> getRGB(Color c) {
      return [c.red, c.blue, c.green];
    }
    

    To use

    Color c = Colors.red;
    print(getRGB(c));