defaultDrawSelected function

void defaultDrawSelected(
  1. DateModel dateModel,
  2. Canvas canvas,
  3. Size size
)

被选中的样式

Implementation

void defaultDrawSelected(DateModel dateModel, Canvas canvas, Size size) {
  //绘制背景
  Paint backGroundPaint = new Paint()
    ..color = Colors.blue
    ..style = PaintingStyle.stroke
    ..strokeWidth = 2;
  double padding = 8;
  canvas.drawRect(
      Rect.fromPoints(Offset(padding, padding),
          Offset(size.width - padding, size.height - padding)),
      backGroundPaint);

  //顶部的文字
  TextPainter dayTextPainter = new TextPainter()
    ..text =
        TextSpan(text: dateModel.day.toString(), style: currentMonthTextStyle)
    ..textDirection = TextDirection.ltr
    ..textAlign = TextAlign.center;

  dayTextPainter.layout(minWidth: size.width, maxWidth: size.width);
  dayTextPainter.paint(canvas, Offset(0, 10));

  //下面的文字
  TextPainter lunarTextPainter = new TextPainter()
    ..text = new TextSpan(text: dateModel.lunarString, style: lunarTextStyle)
    ..textDirection = TextDirection.ltr
    ..textAlign = TextAlign.center;

  lunarTextPainter.layout(minWidth: size.width, maxWidth: size.width);
  lunarTextPainter.paint(canvas, Offset(0, size.height / 2));
}