use_full_hex_values_for_flutter_colors
Instances of 'Color' should be created using an 8-digit hexadecimal integer (such as '0xFFFFFFFF').
Description
#The analyzer produces this diagnostic when the argument to the constructor of the Color
class is a literal integer that isn't represented as an 8-digit hexadecimal integer.
Example
#The following code produces this diagnostic because the argument (1
) isn't represented as an 8-digit hexadecimal integer:
dart
import 'package:flutter/material.dart';
Color c = Color(1);
Common fixes
#Convert the representation to be an 8-digit hexadecimal integer:
dart
import 'package:flutter/material.dart';
Color c = Color(0x00000001);
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.