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) {
  assert(_animationController.isAnimating);

  // InkSparkle can only paint if its shader has been compiled.
  if (_InkSparkleFactory._program == null) {
    // Skipping paintFeature because the shader it relies on is not ready to
    // be used. InkSparkleFactory.initializeShader must complete
    // before InkSparkle can paint.
    return;
  }

  if (!_fragmentShaderInitialized) {
    _fragmentShader = _InkSparkleFactory._program!.fragmentShader();
    _fragmentShaderInitialized = true;
  }

  canvas.save();
  _transformCanvas(canvas: canvas, transform: transform);
  if (_clipCallback != null) {
    _clipCanvas(
      canvas: canvas,
      clipCallback: _clipCallback,
      textDirection: _textDirection,
      customBorder: customBorder,
      borderRadius: _borderRadius,
    );
  }

  _updateFragmentShader();

  final Paint paint = Paint()..shader = _fragmentShader;
  if (_clipCallback != null) {
    canvas.drawRect(_clipCallback(), paint);
  } else {
    canvas.drawPaint(paint);
  }
  canvas.restore();
}