skip to Main Content

I would like a program that does something like this: https://www.colortools.net/color_matcher.html

Anyone know how to do in flutter?

I expect a function that compares two colors.

3

Answers


  1. Chosen as BEST ANSWER

    I looks for an algorithm that uses the result as a percentage. Color difference in %


  2. You can also compare two Colors by directly comparing their int value :

      bool compare(Color color1, Color color2) {
       return color1.value == color2.value;    
      }
    
    final isTwoRedTheSame = compare(Colors.red, Color(0xFFFF0000));
    final isRedEqualsGreen = compare(Colors.red, Colors.green);
    
    print(isTwoColorsSame); // true    
    print(isRedEqualsGreen); // false
    
    Login or Signup to reply.
  3. You can achieve comparison between two colors, is by comparing their degree of RGB, red, green, blue.

        bool compare(Color color1, Color color2) {
        return color1.red == color2.red &&
            color1.green == color2.green &&
            color1.blue == color2.blue;
      }
    
      final isColorsTheSame = compare(Colors.purple, Colors.purple);
      print(isColorsTheSame); // true
    

    Note:

    this will result in a full comparison of two colors, you can also compare only one of the three RGB each separately to get percentage of match.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search