use_full_hex_values_for_flutter_colors
Prefer an 8-digit hexadecimal integer (for example, 0xFFFFFFFF) to instantiate a Color.
This rule is available as of Dart 2.2.
Rule sets: flutter
This rule has a quick fix available.
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);
Usage
#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
除非另有说明,文档之所提及适用于 Dart 3.6.0 版本,本页面最后更新时间: 2024-08-02。 查看文档源码 或者 报告页面问题。