use_full_hex_values_for_flutter_colors
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:
Color(1);
Color(0x000001);
GOOD:
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:
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:
linter:
rules:
use_full_hex_values_for_flutter_colors: true
Unless stated otherwise, the documentation on this site reflects Dart 3.7.0. Page last updated on 2025-01-27. View source or report an issue.