drawText method
绘制文本并返回行高度
when element
not null,then draw gradient
Implementation
double drawText(Canvas canvas, TextPainter? paint, double offsetY,
[LyricsLineModel? element]) {
//paint 理论上不可能为空,预期报错
var lineHeight = paint!.height;
if (offsetY < 0 - lineHeight || offsetY > mSize.height) {
return lineHeight;
}
var isEnableLight = element != null && lyricUI.enableHighlight();
var offset = Offset(getLineOffsetX(paint), offsetY);
if (isEnableLight) {
canvas.saveLayer(
Rect.fromLTWH(0, 0, mSize.width, mSize.height), layerPaint);
}
paint.paint(canvas, offset);
if (isEnableLight) {
drawHighlight(element!, canvas, paint, offset);
canvas.restore();
}
return lineHeight;
}