paint method

  1. @override
void paint (
  1. dynamic canvas,
  2. dynamic size
)

Implementation

@override
void paint(Canvas canvas, Size size) {
  final paint = Paint();
  // cascade notation, look it up it's pretty cool
  Paint line = new Paint()
    ..color = lineColor
    ..strokeCap = StrokeCap.square
    ..style = PaintingStyle.fill
    ..strokeWidth = 6;

  if (first) {
    canvas.drawLine(Offset(size.width / 2, size.height + overflow),
        Offset(size.width / 2, size.height / 2 + 15), line);
  } else if (last) {
    canvas.drawLine(Offset(size.width / 2, size.height / 2 - 15.0),
        Offset(size.width / 2, -overflow), line);
  } else {
    canvas.drawLine(Offset(size.width / 2, (size.height / 2) - 15.0),
        Offset(size.width / 2, -overflow), line);
    canvas.drawLine(Offset(size.width / 2, (size.height / 2) + 15.0),
        Offset(size.width / 2, size.height + overflow), line);
  }

  // set the color property of the paint
  paint.color = circleColor;
  paint.style = PaintingStyle.stroke;
  paint.strokeWidth = 3.0;

  // center of the canvas is (x,y) => (width/2, height/2)
  var center = Offset(size.width / 2, size.height / 2);

  canvas.drawCircle(center, 11.0, paint);
}