use_full_hex_values_for_flutter_colors

Stable
Flutter
Fix available

Prefer an 8-digit hexadecimal integer (for example, 0xFFFFFFFF) to instantiate a Color.

Details

#

PREFER an 8-digit hexadecimal integer (for example, 0xFFFFFFFF) to instantiate a Color. Colors have four 8-bit channels, which adds up to 32 bits, so Colors are described using a 32-bit integer.

BAD:

dart
Color(1);
Color(0x000001);

GOOD:

dart
Color(0x00000001);

Enable

#

To enable the use_full_hex_values_for_flutter_colors rule, add use_full_hex_values_for_flutter_colors under linter > rules in your analysis_options.yaml file:

analysis_options.yaml
yaml
linter:
  rules:
    - use_full_hex_values_for_flutter_colors

If you're instead using the YAML map syntax to configure linter rules, add use_full_hex_values_for_flutter_colors: true under linter > rules:

analysis_options.yaml
yaml
linter:
  rules:
    use_full_hex_values_for_flutter_colors: true