drawPointerIcon method
Draws the gauge pointer icon
Implementation
void drawPointerIcon(Canvas canvas, Size size) {
final pointerIconPainter = TextPainter(
text: TextSpan(
text: String.fromCharCode(pointerIcon.icon!.codePoint),
style: TextStyle(
color: pointerIcon.color == null ? Colors.black : pointerIcon.color,
fontSize: pointerIcon.size == null ? 25 : pointerIcon.size,
package: pointerIcon.icon!.fontPackage,
fontFamily: pointerIcon.icon!.fontFamily,
),
),
textDirection: TextDirection.ltr,
)..layout();
switch (gaugeOrientation) {
case GaugeOrientation.horizontal:
final Offset pointerIconPosition = Offset(
(size.width / 2.5) - pointerIconPainter.width + 30,
getActualValuePosition(size) - (pointerIconPainter.height / 2));
final pivot = pointerIconPainter.size.center(pointerIconPosition);
canvas.save();
canvas.translate(pivot.dx, pivot.dy);
canvas.rotate(RadialHelper.degreesToRadians(-90));
canvas.translate(-pivot.dx, -pivot.dy);
pointerIconPainter.paint(canvas, pointerIconPosition);
canvas.restore();
break;
case GaugeOrientation.vertical:
final Offset pointerIconPosition = Offset(
(size.width / 2.5) - pointerIconPainter.width + 30,
getActualValuePosition(size) - (pointerIconPainter.height / 2));
pointerIconPainter.paint(canvas, pointerIconPosition);
break;
}
}