paintFeature method

  1. @override
void paintFeature (Canvas canvas, 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) {
  final int alpha = _fadeInController.isAnimating ? _fadeIn.value : _fadeOut.value;
  final Paint paint = Paint()..color = color.withAlpha(alpha);
  // Splash moves to the center of the reference box.
  final Offset center = Offset.lerp(
    _position,
    referenceBox.size.center(Offset.zero),
    Curves.ease.transform(_radiusController.value),
  );
  final Offset originOffset = MatrixUtils.getAsTranslation(transform);
  canvas.save();
  if (originOffset == null) {
    canvas.transform(transform.storage);
  } else {
    canvas.translate(originOffset.dx, originOffset.dy);
  }
  if (_clipCallback != null) {
    final Rect rect = _clipCallback();
    if (_customBorder != null) {
      canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection));
    } else if (_borderRadius != BorderRadius.zero) {
      canvas.clipRRect(RRect.fromRectAndCorners(
        rect,
        topLeft: _borderRadius.topLeft, topRight: _borderRadius.topRight,
        bottomLeft: _borderRadius.bottomLeft, bottomRight: _borderRadius.bottomRight,
      ));
    } else {
      canvas.clipRect(rect);
    }
  }
  canvas.drawCircle(center, _radius.value, paint);
  canvas.restore();
}