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

Commit 9a1e419

Browse files
authored
test: added test case in prefer_const_border_radius rule (#876)
* fix: added test case * fix: added test case * fix: added test case * fix: change const to final Border.all
1 parent 169f6ae commit 9a1e419

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
* test: added test case in [`prefer-const-border-radius`](https://dartcodemetrics.dev/docs/rules/flutter/prefer-const-border-radius) rule.
56
* chore: restrict `analyzer` version to `>=2.4.0 <4.2.0`.
67
* fix: improve context root included files calculation.
78

test/src/analyzers/lint_analyzer/rules/rules_list/prefer_const_border_radius/examples/example.dart

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,42 @@ class MyWidget extends StatelessWidget {
2626
_constValue == 10.0 ? 25.0 : 30.0,
2727
),
2828
),
29+
ClipRRect(
30+
decoration: BoxDecoration(
31+
shape: BoxShape.circle,
32+
border: Border.all(
33+
width: ringWidth,
34+
color: Colors.gray,
35+
),
36+
),
37+
),
2938
]);
3039
}
3140
}
3241

42+
class Colors {
43+
static const gray = Color(0xFF000000);
44+
}
45+
46+
class Color {
47+
final int value;
48+
49+
const Color(int value) : value = value & 0xFFFFFFFF;
50+
}
51+
52+
enum BoxShape { circle }
53+
54+
final _kDefaultRingWidth = 3;
55+
final _scaling = 3.0;
56+
final ringWidth = _kDefaultRingWidth * _scaling;
57+
58+
class BoxDecoration {
59+
final BoxShape? shape;
60+
final Border? border;
61+
62+
const BoxDecoration({this.shape, this.border});
63+
}
64+
3365
class BorderRadius {
3466
final Radius topLeft;
3567
final Radius topRight;
@@ -54,6 +86,18 @@ class BorderRadius {
5486
});
5587
}
5688

89+
class BorderSide {}
90+
91+
class Border {
92+
final Color? color;
93+
final double? width;
94+
95+
const Border.all({
96+
this.width,
97+
this.color,
98+
});
99+
}
100+
57101
class Radius {
58102
final double x;
59103
final double y;
@@ -68,8 +112,9 @@ class Radius {
68112
class ClipRRect extends Widget {
69113
final Widget? child;
70114
final BorderRadius? borderRadius;
115+
final BoxDecoration? decoration;
71116

72-
const ClipRRect({this.child, this.borderRadius});
117+
const ClipRRect({this.child, this.borderRadius, this.decoration});
73118
}
74119

75120
class Column extends Widget {

0 commit comments

Comments
 (0)