enable lint use_full_hex_values_for_flutter_colors (#35056)

This commit is contained in:
Alexandre Ardhuin 2019-06-25 17:58:19 +02:00 committed by GitHub
parent fecf99ff1e
commit b5ce06163c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 138 additions and 138 deletions

View file

@ -182,7 +182,7 @@ linter:
- unnecessary_this
- unrelated_type_equality_checks
# - unsafe_html # not yet tested
# - use_full_hex_values_for_flutter_colors # not yet tested
- use_full_hex_values_for_flutter_colors
# - use_function_type_syntax_for_parameters # not yet tested
- use_rethrow_when_possible
# - use_setters_to_change_properties # not yet tested

View file

@ -203,8 +203,8 @@ void main() {
testWidgets('Can specify colors', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(child: CupertinoButton(
child: const Text('Skeuomorph me'),
color: const Color(0x0000FF),
disabledColor: const Color(0x00FF00),
color: const Color(0x000000FF),
disabledColor: const Color(0x0000FF00),
onPressed: () { },
)));
@ -212,12 +212,12 @@ void main() {
find.widgetWithText(DecoratedBox, 'Skeuomorph me')
).decoration;
expect(boxDecoration.color, const Color(0x0000FF));
expect(boxDecoration.color, const Color(0x000000FF));
await tester.pumpWidget(boilerplate(child: const CupertinoButton(
child: Text('Skeuomorph me'),
color: Color(0x0000FF),
disabledColor: Color(0x00FF00),
color: Color(0x000000FF),
disabledColor: Color(0x0000FF00),
onPressed: null,
)));
@ -225,7 +225,7 @@ void main() {
find.widgetWithText(DecoratedBox, 'Skeuomorph me')
).decoration;
expect(boxDecoration.color, const Color(0x00FF00));
expect(boxDecoration.color, const Color(0x0000FF00));
});
testWidgets('Button respects themes', (WidgetTester tester) async {

View file

@ -600,11 +600,11 @@ void main() {
child: CupertinoTextField(
placeholder: 'placeholder',
style: TextStyle(
color: Color(0X00FFFFFF),
color: Color(0x00FFFFFF),
fontWeight: FontWeight.w300,
),
placeholderStyle: TextStyle(
color: Color(0XAAFFFFFF),
color: Color(0xAAFFFFFF),
fontWeight: FontWeight.w600
),
),
@ -613,14 +613,14 @@ void main() {
);
final Text placeholder = tester.widget(find.text('placeholder'));
expect(placeholder.style.color, const Color(0XAAFFFFFF));
expect(placeholder.style.color, const Color(0xAAFFFFFF));
expect(placeholder.style.fontWeight, FontWeight.w600);
await tester.enterText(find.byType(CupertinoTextField), 'input');
await tester.pump();
final EditableText inputText = tester.widget(find.text('input'));
expect(inputText.style.color, const Color(0X00FFFFFF));
expect(inputText.style.color, const Color(0x00FFFFFF));
expect(inputText.style.fontWeight, FontWeight.w300);
},
);

View file

@ -199,8 +199,8 @@ void main() {
});
testWidgets('Custom selected and unselected icon themes', (WidgetTester tester) async {
const IconThemeData selectedIconTheme = IconThemeData(size: 36, color: Color(1));
const IconThemeData unselectedIconTheme = IconThemeData(size: 18, color: Color(2));
const IconThemeData selectedIconTheme = IconThemeData(size: 36, color: Color(0x00000001));
const IconThemeData unselectedIconTheme = IconThemeData(size: 18, color: Color(0x00000002));
await tester.pumpWidget(
MaterialApp(
@ -233,10 +233,10 @@ void main() {
});
testWidgets('color on icon theme overrides selected and unselected item colors', (WidgetTester tester) async {
const IconThemeData selectedIconTheme = IconThemeData(size: 36, color: Color(1));
const IconThemeData unselectedIconTheme = IconThemeData(size: 18, color: Color(2));
const Color selectedItemColor = Color(3);
const Color unselectedItemColor = Color(4);
const IconThemeData selectedIconTheme = IconThemeData(size: 36, color: Color(0x00000001));
const IconThemeData unselectedIconTheme = IconThemeData(size: 18, color: Color(0x00000002));
const Color selectedItemColor = Color(0x00000003);
const Color unselectedItemColor = Color(0x00000004);
await tester.pumpWidget(
MaterialApp(

View file

@ -70,7 +70,7 @@ void main() {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(accentColor: const Color(1)),
theme: ThemeData(accentColor: const Color(0x00000001)),
home: Builder(
builder: (BuildContext context) {
return Center(
@ -104,7 +104,7 @@ void main() {
),
);
expect(tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)).textStyle.color, const Color(1));
expect(tester.widget<RawMaterialButton>(find.byType(RawMaterialButton)).textStyle.color, const Color(0x00000001));
// Show the dialog
await tester.tap(find.text('button'));
@ -114,6 +114,6 @@ void main() {
of: find.text('enabled'),
matching: find.byType(RawMaterialButton),
);
expect(tester.widget<RawMaterialButton>(dialogButton).textStyle.color, const Color(1));
expect(tester.widget<RawMaterialButton>(dialogButton).textStyle.color, const Color(0x00000001));
});
}

View file

@ -331,10 +331,10 @@ void main() {
testWidgets('button theme with stateful color changes color in states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
const Color pressedColor = Color(1);
const Color hoverColor = Color(2);
const Color focusedColor = Color(3);
const Color defaultColor = Color(4);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
const Color focusedColor = Color(0x00000003);
const Color defaultColor = Color(0x00000004);
Color getTextColor(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {

View file

@ -14,42 +14,42 @@ void main() {
const MaterialColor color = MaterialColor(
500,
<int, Color>{
50: Color(50),
100: Color(100),
200: Color(200),
300: Color(300),
400: Color(400),
500: Color(500),
600: Color(600),
700: Color(700),
800: Color(800),
900: Color(900),
50: Color(0x00000050),
100: Color(0x00000100),
200: Color(0x00000200),
300: Color(0x00000300),
400: Color(0x00000400),
500: Color(0x00000500),
600: Color(0x00000600),
700: Color(0x00000700),
800: Color(0x00000800),
900: Color(0x00000900),
},
);
expect(color.value, 500);
expect(color[50].value, 50);
expect(color[100].value, 100);
expect(color[200].value, 200);
expect(color[300].value, 300);
expect(color[400].value, 400);
expect(color[500].value, 500);
expect(color[600].value, 600);
expect(color[700].value, 700);
expect(color[800].value, 800);
expect(color[900].value, 900);
expect(color[50].value, 0x00000050);
expect(color[100].value, 0x00000100);
expect(color[200].value, 0x00000200);
expect(color[300].value, 0x00000300);
expect(color[400].value, 0x00000400);
expect(color[500].value, 0x00000500);
expect(color[600].value, 0x00000600);
expect(color[700].value, 0x00000700);
expect(color[800].value, 0x00000800);
expect(color[900].value, 0x00000900);
expect(color.shade50.value, 50);
expect(color.shade100.value, 100);
expect(color.shade200.value, 200);
expect(color.shade300.value, 300);
expect(color.shade400.value, 400);
expect(color.shade500.value, 500);
expect(color.shade600.value, 600);
expect(color.shade700.value, 700);
expect(color.shade800.value, 800);
expect(color.shade900.value, 900);
expect(color.shade50.value, 0x00000050);
expect(color.shade100.value, 0x00000100);
expect(color.shade200.value, 0x00000200);
expect(color.shade300.value, 0x00000300);
expect(color.shade400.value, 0x00000400);
expect(color.shade500.value, 0x00000500);
expect(color.shade600.value, 0x00000600);
expect(color.shade700.value, 0x00000700);
expect(color.shade800.value, 0x00000800);
expect(color.shade900.value, 0x00000900);
});
test('Colors swatches do not contain duplicates', () {

View file

@ -147,10 +147,10 @@ void main() {
testWidgets('FlatButton uses stateful color for text color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
const Color pressedColor = Color(1);
const Color hoverColor = Color(2);
const Color focusedColor = Color(3);
const Color defaultColor = Color(4);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
const Color focusedColor = Color(0x00000003);
const Color defaultColor = Color(0x00000004);
Color getTextColor(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
@ -214,10 +214,10 @@ void main() {
final FocusNode focusNode = FocusNode();
final Key buttonKey = UniqueKey();
const Color pressedColor = Color(1);
const Color hoverColor = Color(2);
const Color focusedColor = Color(3);
const Color defaultColor = Color(4);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
const Color focusedColor = Color(0x00000003);
const Color defaultColor = Color(0x00000004);
Color getTextColor(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
@ -279,9 +279,9 @@ void main() {
testWidgets('FlatButton ignores disabled text color if text color is stateful', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
const Color disabledColor = Color(1);
const Color defaultColor = Color(2);
const Color unusedDisabledTextColor = Color(3);
const Color disabledColor = Color(0x00000001);
const Color defaultColor = Color(0x00000002);
const Color unusedDisabledTextColor = Color(0x00000003);
Color getTextColor(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {

View file

@ -3015,8 +3015,8 @@ void main() {
suffixStyle: TextStyle(height: 8.0),
counterStyle: TextStyle(height: 9.0),
filled: true,
fillColor: Color(0x10),
focusColor: Color(0x20),
fillColor: Color(0x00000010),
focusColor: Color(0x00000020),
errorBorder: UnderlineInputBorder(),
focusedBorder: OutlineInputBorder(),
focusedErrorBorder: UnderlineInputBorder(),

View file

@ -150,10 +150,10 @@ void main() {
testWidgets('OutlineButton uses stateful color for text color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
const Color pressedColor = Color(1);
const Color hoverColor = Color(2);
const Color focusedColor = Color(3);
const Color defaultColor = Color(4);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
const Color focusedColor = Color(0x00000003);
const Color defaultColor = Color(0x00000004);
Color getTextColor(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
@ -217,10 +217,10 @@ void main() {
final FocusNode focusNode = FocusNode();
final Key buttonKey = UniqueKey();
const Color pressedColor = Color(1);
const Color hoverColor = Color(2);
const Color focusedColor = Color(3);
const Color defaultColor = Color(4);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
const Color focusedColor = Color(0x00000003);
const Color defaultColor = Color(0x00000004);
Color getTextColor(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
@ -282,9 +282,9 @@ void main() {
testWidgets('OutlineButton ignores disabled text color if text color is stateful', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
const Color disabledColor = Color(1);
const Color defaultColor = Color(2);
const Color unusedDisabledTextColor = Color(3);
const Color disabledColor = Color(0x00000001);
const Color defaultColor = Color(0x00000002);
const Color unusedDisabledTextColor = Color(0x00000003);
Color getTextColor(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
@ -425,7 +425,7 @@ void main() {
..path(color: disabledBorderColor, strokeWidth: borderWidth));
_checkPhysicalLayer(
tester.element(outlineButton),
const Color(0),
const Color(0x00000000),
clipPath: clipPath,
clipRect: clipRect,
);

View file

@ -82,10 +82,10 @@ void main() {
testWidgets('RaisedButton uses stateful color for text color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
const Color pressedColor = Color(1);
const Color hoverColor = Color(2);
const Color focusedColor = Color(3);
const Color defaultColor = Color(4);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
const Color focusedColor = Color(0x00000003);
const Color defaultColor = Color(0x00000004);
Color getTextColor(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
@ -150,10 +150,10 @@ void main() {
final FocusNode focusNode = FocusNode();
final Key buttonKey = UniqueKey();
const Color pressedColor = Color(1);
const Color hoverColor = Color(2);
const Color focusedColor = Color(3);
const Color defaultColor = Color(4);
const Color pressedColor = Color(0x00000001);
const Color hoverColor = Color(0x00000002);
const Color focusedColor = Color(0x00000003);
const Color defaultColor = Color(0x00000004);
Color getTextColor(Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
@ -215,9 +215,9 @@ void main() {
testWidgets('RaisedButton ignores disabled text color if text color is stateful', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
const Color disabledColor = Color(1);
const Color defaultColor = Color(2);
const Color unusedDisabledTextColor = Color(3);
const Color disabledColor = Color(0x00000001);
const Color defaultColor = Color(0x00000002);
const Color unusedDisabledTextColor = Color(0x00000003);
Color getTextColor(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {

View file

@ -2282,8 +2282,8 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/15008.
testWidgets('TabBar with one tab has correct color', (WidgetTester tester) async {
const Tab tab = Tab(text: 'A');
const Color selectedTabColor = Color(1);
const Color unselectedTabColor = Color(2);
const Color selectedTabColor = Color(0x00000001);
const Color unselectedTabColor = Color(0x00000002);
await tester.pumpWidget(boilerplate(
child: const DefaultTabController(

View file

@ -74,10 +74,10 @@ void main() {
// The `displayColor` is applied to [display4], [display3], [display2],
// [display1], and [caption]. The `bodyColor` is applied to the remaining
// text styles.
const Color displayColor = Color(1);
const Color bodyColor = Color(2);
const Color displayColor = Color(0x00000001);
const Color bodyColor = Color(0x00000002);
const String fontFamily = 'fontFamily';
const Color decorationColor = Color(3);
const Color decorationColor = Color(0x00000003);
const TextDecorationStyle decorationStyle = TextDecorationStyle.dashed;
final TextDecoration decoration = TextDecoration.combine(<TextDecoration>[
TextDecoration.underline,

View file

@ -251,7 +251,7 @@ void main() {
});
test('mutating ShaderMaskLayer fields triggers needsAddToScene', () {
const Gradient gradient = RadialGradient(colors: <Color>[Color(0), Color(1)]);
const Gradient gradient = RadialGradient(colors: <Color>[Color(0x00000000), Color(0x00000001)]);
final Shader shader = gradient.createShader(Rect.zero);
final ShaderMaskLayer layer = ShaderMaskLayer(shader: shader, maskRect: Rect.zero, blendMode: BlendMode.clear);
checkNeedsAddToScene(layer, () {
@ -274,7 +274,7 @@ void main() {
test('mutating PhysicalModelLayer fields triggers needsAddToScene', () {
final PhysicalModelLayer layer = PhysicalModelLayer(
clipPath: Path(), elevation: 0, color: const Color(0), shadowColor: const Color(0));
clipPath: Path(), elevation: 0, color: const Color(0x00000000), shadowColor: const Color(0x00000000));
checkNeedsAddToScene(layer, () {
final Path newPath = Path();
newPath.addRect(unitRect);
@ -284,10 +284,10 @@ void main() {
layer.elevation = 1;
});
checkNeedsAddToScene(layer, () {
layer.color = const Color(1);
layer.color = const Color(0x00000001);
});
checkNeedsAddToScene(layer, () {
layer.shadowColor = const Color(1);
layer.shadowColor = const Color(0x00000001);
});
});
@ -330,14 +330,14 @@ void main() {
final PhysicalModelLayer layerA = PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(0, 0, 20, 20)),
elevation: 3.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
);
final PhysicalModelLayer layerB =PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(10, 10, 20, 20)),
elevation: 2.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
);
_testConflicts(layerA, layerB, expectedErrorCount: 1);
});
@ -354,14 +354,14 @@ void main() {
final PhysicalModelLayer layerA = PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(0, 0, 20, 20)),
elevation: 3.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
);
final PhysicalModelLayer layerB =PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(10, 10, 20, 20)),
elevation: 2.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
);
_testConflicts(layerA, layerB, expectedErrorCount: 0, enableCheck: false);
});
@ -376,14 +376,14 @@ void main() {
final PhysicalModelLayer layerA = PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(0, 0, 20, 20)),
elevation: 3.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
);
final PhysicalModelLayer layerB =PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(20, 20, 20, 20)),
elevation: 2.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
);
_testConflicts(layerA, layerB, expectedErrorCount: 0);
});
@ -400,22 +400,22 @@ void main() {
final PhysicalModelLayer layerA = PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(0, 0, 20, 20)),
elevation: 3.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
);
layerA.append(PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(2, 2, 10, 10)),
elevation: 1.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
));
final PhysicalModelLayer layerB =PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(20, 20, 20, 20)),
elevation: 2.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
);
_testConflicts(layerA, layerB, expectedErrorCount: 0);
});
@ -435,22 +435,22 @@ void main() {
final PhysicalModelLayer layerA = PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(0, 0, 20, 20)),
elevation: 3.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
);
layerA.append(PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(15, 15, 25, 25)),
elevation: 2.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
));
final PhysicalModelLayer layerB =PhysicalModelLayer(
clipPath: Path()..addRect(const Rect.fromLTWH(20, 20, 20, 20)),
elevation: 4.0,
color: const Color(0),
shadowColor: const Color(0),
color: const Color(0x00000000),
shadowColor: const Color(0x00000000),
);
_testConflicts(layerA, layerB, expectedErrorCount: 1);

View file

@ -63,12 +63,12 @@ void main() {
});
test('TableBorder.lerp', () {
const BorderSide side1 = BorderSide(width: 1.0, color: Color(1));
const BorderSide side2 = BorderSide(width: 2.0, color: Color(2));
const BorderSide side3 = BorderSide(width: 3.0, color: Color(3));
const BorderSide side4 = BorderSide(width: 4.0, color: Color(4));
const BorderSide side5 = BorderSide(width: 5.0, color: Color(5));
const BorderSide side6 = BorderSide(width: 6.0, color: Color(6));
const BorderSide side1 = BorderSide(width: 1.0, color: Color(0x00000001));
const BorderSide side2 = BorderSide(width: 2.0, color: Color(0x00000002));
const BorderSide side3 = BorderSide(width: 3.0, color: Color(0x00000003));
const BorderSide side4 = BorderSide(width: 4.0, color: Color(0x00000004));
const BorderSide side5 = BorderSide(width: 5.0, color: Color(0x00000005));
const BorderSide side6 = BorderSide(width: 6.0, color: Color(0x00000006));
const TableBorder tableA = TableBorder(
top: side1,
right: side2,

View file

@ -28,38 +28,38 @@ class FooState extends State<Foo> {
scrollController.animateTo(200.0, duration: const Duration(milliseconds: 500), curve: Curves.linear);
},
child: const DecoratedBox(
decoration: BoxDecoration(color: Color(0)),
decoration: BoxDecoration(color: Color(0x00000000)),
child: SizedBox(
height: 200.0,
),
),
),
const DecoratedBox(
decoration: BoxDecoration(color: Color(0)),
decoration: BoxDecoration(color: Color(0x00000000)),
child: SizedBox(
height: 200.0,
),
),
const DecoratedBox(
decoration: BoxDecoration(color: Color(0)),
decoration: BoxDecoration(color: Color(0x00000000)),
child: SizedBox(
height: 200.0,
),
),
const DecoratedBox(
decoration: BoxDecoration(color: Color(0)),
decoration: BoxDecoration(color: Color(0x00000000)),
child: SizedBox(
height: 200.0,
),
),
const DecoratedBox(
decoration: BoxDecoration(color: Color(0)),
decoration: BoxDecoration(color: Color(0x00000000)),
child: SizedBox(
height: 200.0,
),
),
const DecoratedBox(
decoration: BoxDecoration(color: Color(0)),
decoration: BoxDecoration(color: Color(0x00000000)),
child: SizedBox(
height: 200.0,
),

View file

@ -736,13 +736,13 @@ void main() {
child: Text.rich(
TextSpan(
text: 'inner',
style: TextStyle(color: Color(0xff402f4ff)),
style: TextStyle(color: Color(0xf402f4ff)),
children: <InlineSpan>[
WidgetSpan(
child: Text.rich(
TextSpan(
text: 'inner2',
style: TextStyle(color: Color(0xff003ffff)),
style: TextStyle(color: Color(0xf003ffff)),
children: <InlineSpan>[
WidgetSpan(
child: SizedBox(

View file

@ -40,7 +40,7 @@ void main() {
testWidgets('should not allow non-opaque color', (WidgetTester tester) async {
expect(() => Title(
color: const Color(0),
color: const Color(0x00000000),
child: Container(),
), throwsAssertionError);
});