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 color = Color.lerp(from, to, t)!;

  // We're creating a shader here because [ShadedElement] component
  // will use a shader mask to shade original elements
  //
  // todo: find a better way to create a one-color shader!
  return Paint()
    ..shader = LinearGradient(
      colors: [color, color],
    ).createShader(rect);
}