createPaint method

  1. @override
Paint createPaint(
  1. double t,
  2. Rect rect,
  3. TextDirection? textDirection
)
override

Evaluates the painting effect at animation value t

typically used to create shaders e.g LinearGradient shaders

Implementation

@override
Paint createPaint(double t, Rect rect, TextDirection? textDirection) {
  final beginX = begin.resolve(textDirection).x;
  final endX = end.resolve(textDirection).x;
  final isVertical = beginX == 0 && endX == 0;
  return Paint()
    ..shader = LinearGradient(
      colors: colors,
      stops: stops,
      begin: begin,
      end: end,
      tileMode: tileMode,
      transform: _SlidingGradientTransform(offset: t, isVertical: isVertical),
    ).createShader(rect, textDirection: textDirection);
}