We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b799343 commit dc23be5Copy full SHA for dc23be5
3 files changed
lib/src/chart/bar_chart/bar_chart_data.dart
@@ -299,20 +299,6 @@ class BarChartGroupData with EquatableMixin {
299
];
300
}
301
302
-Border? _normalizeBorder(Border? border, double width) {
303
- if (border == null) {
304
- return null;
305
- }
306
-
307
- final utils = Utils();
308
- return Border(
309
- top: utils.normalizeBorderSide(border.top, width),
310
- right: utils.normalizeBorderSide(border.right, width),
311
- bottom: utils.normalizeBorderSide(border.bottom, width),
312
- left: utils.normalizeBorderSide(border.left, width),
313
- );
314
-}
315
316
/// Holds data about rendering each rod (or bar) in the [BarChart].
317
class BarChartRodData with EquatableMixin {
318
/// [BarChart] renders rods vertically from zero to [toY],
@@ -364,7 +350,7 @@ class BarChartRodData with EquatableMixin {
364
350
width = width ?? 8,
365
351
borderRadius = Utils().normalizeBorderRadius(borderRadius, width ?? 8),
366
352
borderSide = Utils().normalizeBorderSide(borderSide, width ?? 8),
367
- border = _normalizeBorder(border, width ?? 8),
353
+ border = Utils().normalizeBorder(border, width ?? 8),
368
354
backDrawRodData = backDrawRodData ?? BackgroundBarChartRodData(),
369
355
rodStackItems = rodStackItems ?? const [];
370
356
lib/src/utils/utils.dart
@@ -107,6 +107,20 @@ class Utils {
107
return borderSide.copyWith(width: borderWidth);
108
109
110
+ /// Decreases each side of [border] to <= width / 2.
111
+ Border? normalizeBorder(Border? border, double width) {
112
+ if (border == null) {
113
+ return null;
114
+ }
115
+
116
+ return Border(
117
+ top: normalizeBorderSide(border.top, width),
118
+ right: normalizeBorderSide(border.right, width),
119
+ bottom: normalizeBorderSide(border.bottom, width),
120
+ left: normalizeBorderSide(border.left, width),
121
+ );
122
123
124
/// Returns an efficient interval for showing axis titles, or grid lines or ...
125
///
126
/// If there isn't any provided interval, we use this function to calculate an interval to apply,
test/utils/utils_test.dart
@@ -115,6 +115,32 @@ void main() {
expect(Utils().normalizeBorderSide(input2, 40), output2);
});
+ test('normalizeBorder()', () {
+ const input1 = Border(
+ top: BorderSide(width: 4),
+ right: BorderSide(width: 8),
+ bottom: BorderSide(width: 10),
+ left: BorderSide(width: 2),
+ const output1 = input1;
+ expect(Utils().normalizeBorder(input1, 40), output1);
127
128
+ const input2 = Border(
129
+ top: BorderSide(width: 24),
130
+ right: BorderSide(width: 30),
131
+ bottom: BorderSide(width: 21),
132
+ left: BorderSide(),
133
134
+ const output2 = Border(
135
+ top: BorderSide(width: 20),
136
+ right: BorderSide(width: 20),
137
+ bottom: BorderSide(width: 20),
138
139
140
+ expect(Utils().normalizeBorder(input2, 40), output2);
141
+ expect(Utils().normalizeBorder(null, 40), isNull);
142
+ });
143
144
test('lerp gradient', () {
145
expect(
146
lerpGradient(
0 commit comments