use-full-hex-values-for-flutter-colors
Same as use_full_hex_values_for_flutter_colors in Dart lints
- Group
- Style
- Path
lint/style/use-full-hex-values-for-flutter-colors- Default
- On (recommended)
- Origin
- Dart lints
- Domain
- flutter
- Rule
- 490 of 512
Require an eight-digit hexadecimal integer for the canonical Flutter Color default constructor.
Invalid
// Bad: Color constructed with fewer than 8 hex digits.
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
final c0 = Color(0xFFFFFF);
final c1 = Color(0x00FF00);
final c2 = Color(0xABC);
final c3 = Color(0Xff0000);
final c4 = Color(0xF);
final c5 = Color(0xFF00FF);
final c6 = ui.Color(16777215);
final c7 = ui.Color(0x1FFFFFFFF);
final c8 = ui.Color(0xFF_FF_FF);
final c9 = const Color(0xFFFFFF); final c0 = Color(0xFFFFFF); final c1 = Color(0x00FF00); final c2 = Color(0xABC); final c3 = Color(0Xff0000); final c4 = Color(0xF); final c5 = Color(0xFF00FF); final c6 = ui.Color(16777215);final c6 = ui.Color(16777215);final c7 = ui.Color(0x1FFFFFFFF);final c7 = ui.Color(0x1FFFFFFFF);final c8 = ui.Color(0xFF_FF_FF); final c9 = const Color(0xFFFFFF);Valid
// Good: full 8-digit hex colors, or not a bare Color() call.
import 'package:flutter/material.dart';
final c0 = Color(0xFFFFFFFF);
final c1 = Color(0x00FF00FF);
final c2 = Color(0xFF123456);
final c3 = Colors.red;
final c4 = Color.fromARGB(255, 0, 0, 0);
final c5 = Color(0xFFAABBCC);
final c6 = const Color.fromARGB(255, 0, 0, 1);
final c7 = const Color(0xFFAABBCC);Configure use-full-hex-values-for-flutter-colors
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"use-full-hex-values-for-flutter-colors": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/use-full-hex-values-for-flutter-colors: <reason>More style rules
- use-function-type-syntax-for-parameters
use_function_type_syntax_for_parametersrecommendedFlags an old-style function-typed parameter written with inline parameter syntax.
- use-if-null-to-convert-nulls-to-bools
use_if_null_to_convert_nulls_to_boolsrecommendedPrefers
??to comparing a nullableboolagainst a boolean literal. - use-late-for-private-fields-and-variables
use_late_for_private_fields_and_variablesFlags a private nullable field or top-level variable that is only ever assigned non-null values and read through
!, so it could belatewith a non-nullable type. - use-named-constants
use_named_constantsrecommendedPrefers a class's predefined static constant to constructing an equal constant.
- use-raw-strings
use_raw_stringsFlags string literals whose only escapes are
\\and\$, which a raw string would express without any backslash. - use-setters-to-change-properties
use_setters_to_change_propertiesFlags one-parameter
voidmethods that only assign that parameter to a field. - use-spacer-as-expanded-child
use_spacer_as_expanded_childrecommendedflutterFlags an
Expandedwrapping an emptySizedBoxorContainerthat should be aSpacer. - use-string-in-part-of-directives
use_string_in_part_of_directivesrecommendedFlags a
part ofdirective that names its library instead of using a string URI.