draw method
Draw decoration. Decoration can be foreground or background decoration that will be drawn on the chart decorations can ignore padding and can use whole available canvas to draw.
Implementation
@override
void draw(Canvas canvas, Size size, ChartState state) {
final _paint = Paint()
..style = PaintingStyle.stroke
..color = color;
final _height = size.height + _borderWidth.dimensions.vertical;
final _width = size.width - _borderWidth.dimensions.horizontal;
_paint.strokeWidth = _borderWidth.top.width;
_paint.color = _borderWidth.top.color;
_drawLine(
canvas,
Offset(0.0, _borderWidth.top.width / 2),
Offset(_width + _borderWidth.dimensions.horizontal,
_borderWidth.top.width / 2),
_paint,
);
_paint.strokeWidth = _borderWidth.right.width;
_paint.color = _borderWidth.right.color;
_drawLine(
canvas,
Offset(_width + _borderWidth.left.width + _borderWidth.right.width / 2,
_borderWidth.top.width),
Offset(
_width + _borderWidth.left.width + _borderWidth.right.width / 2,
_height -
_borderWidth.dimensions.vertical -
_borderWidth.bottom.width),
_paint);
_paint.strokeWidth = _borderWidth.bottom.width;
_paint.color = _borderWidth.bottom.color;
_drawLine(
canvas,
Offset(
_width + _borderWidth.dimensions.horizontal,
_height -
_borderWidth.dimensions.vertical -
(_borderWidth.bottom.width / 2)),
Offset(
0.0,
_height -
_borderWidth.dimensions.vertical -
(_borderWidth.bottom.width / 2)),
_paint);
_paint.strokeWidth = _borderWidth.left.width;
_paint.color = _borderWidth.left.color;
_drawLine(
canvas,
Offset(
-_borderWidth.left.width +
_borderWidth.dimensions.horizontal -
(_borderWidth.left.width / 2),
_height -
_borderWidth.dimensions.vertical -
_borderWidth.bottom.width),
Offset(
-_borderWidth.left.width +
_borderWidth.dimensions.horizontal -
(_borderWidth.left.width / 2),
_borderWidth.top.width),
_paint);
}