Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

fix: avoid-border-all is triggered even when it is not a const #841

Merged
merged 2 commits into from May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

* fix: [`avoid-border-all`](https://dartcodemetrics.dev/docs/rules/flutter/avoid-border-all) is triggered even when it is not a const.

## 4.15.1

* chore: restrict `analyzer` version to `>=2.4.0 <4.1.0`.
Expand Down
Expand Up @@ -21,7 +21,9 @@ class _Visitor extends RecursiveAstVisitor<void> {
final arg = (argument as NamedExpression).expression;
if (arg is Literal) {
continue;
} else if (arg is MethodInvocation || arg is ConditionalExpression) {
} else if (arg is MethodInvocation ||
arg is ConditionalExpression ||
arg is PropertyAccess) {
isAllConst = false;
} else if (arg is SimpleIdentifier) {
final element = arg.staticElement;
Expand Down
@@ -1,5 +1,5 @@
class MyWidget extends StatelessWidget {
Widget build(BuildContext _) => Column(children: [
Widget build(BuildContext context) => Column(children: [
const Container(border: Border.fromBorderSide(BorderSide())),
Container(border: Border.all()), // LINT
Container(
Expand Down Expand Up @@ -27,6 +27,11 @@ class MyWidget extends StatelessWidget {
style: BorderStyle.none,
),
),
Container(
border: Border.all(
color: Theme.of(context).color,
),
),
Container(
border: Border.all(
color: const Color(0),
Expand Down Expand Up @@ -106,3 +111,9 @@ class Widget {
}

class BuildContext {}

class Theme {
const color = Color(0);

static Color of(BuildContext context) => color;
}