Skip to content

Commit

Permalink
fix: Exclude Colors.transparent from the target of avoid_hardcoded_co…
Browse files Browse the repository at this point in the history
…lor (#63)

* fix: Colors.transparent from the target of avoid_hardcoded_color

* fix:revison
  • Loading branch information
boywithdv authored Oct 7, 2024
1 parent c538080 commit f1a1f5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class AvoidHardcodedColor extends DartLintRule {
final element = node.staticElement;
if (element is PropertyAccessorElement) {
final returnType = element.returnType;
// Allow Colors.transparent as a valid hardcoded color, as it serves.
if (node.identifier.name == 'transparent') {
return;
}
if (_isColorType(returnType)) {
reporter.atNode(node, _code);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class MyWidget extends StatelessWidget {
// expect_lint: avoid_hardcoded_color
const ColoredBox(color: Colors.green),
ColoredBox(color: Theme.of(context).colorScheme.primary),

const ColoredBox(color: Colors.transparent),
],
);
}
Expand Down

0 comments on commit f1a1f5f

Please sign in to comment.