An invalid color definition may be interpreted incorrectly, which is likely to have unintended impacts on the expected look and feel of the UI.
That’s why it’s important to use a 8-digit hexadecimal integer (0xFFFFFFFF)
when creating a Color
object with
Color(int)
constructor. If only 6-digit hex value was used, the 2 leading digits will be considered 0
and interpreted as
fully-transparent. Most likely this is not the desired behavior. To avoid such mistakes, either use a different constructor, or use a 8-digit
hexadecimal value.
Noncompliant code example
Color c1 = const Color(0x42A5F5);
Color c2 = const Color(42);
Compliant solution
Color c1 = const Color(0xFF42A5F5);
Color c2 = const Color.fromARGB(0xFF, 0x42, 0xA5, 0xF5);