paintFeature method

  1. @override
void paintFeature(
  1. Canvas canvas,
  2. Matrix4 transform
)
override

Override this method to paint the ink feature.

The transform argument gives the coordinate conversion from the coordinate system of the canvas to the coordinate system of the referenceBox.

Implementation

@override
void paintFeature(Canvas canvas, Matrix4 transform) {
  // TODO: add support for rtl

  final progress = _progressAnimation.value;
  if (progress == 0) {
    return;
  }
  final rect = referenceBox.size;

  const double startX = 0;
  final startY = rect.height / 2;
  final endX = rect.width * progress;
  var path = Path();
  path.moveTo(startX, startY);
  path.lineTo(endX, startY);

  // the matrix is a 2D translation, so this never returns null
  final originOffset = MatrixUtils.getAsTranslation(transform)!;
  path = path.shift(originOffset);
  canvas.drawPath(path, paint);
}