paint method
Implementation
@override
void paint(Context context, PdfRect box) {
if (colors.isEmpty) {
return;
}
if (colors.length == 1) {
context.canvas
..setFillColor(colors.first)
..fillPath();
}
assert(stops == null || stops!.length == colors.length);
final _focal = focal ?? center;
final _radius = math.min(box.width, box.height);
final textDirection = Directionality.of(context);
context.canvas
..saveContext()
..clipPath()
..applyShader(
PdfShading(
context.document,
shadingType: PdfShadingType.radial,
boundingBox: box,
function: PdfBaseFunction.colorsAndStops(
context.document,
colors,
stops,
),
start: _focal.resolve(textDirection).withinRect(box),
end: center.resolve(textDirection).withinRect(box),
radius0: focalRadius * _radius,
radius1: radius * _radius,
extendStart: true,
extendEnd: true,
),
)
..restoreContext();
}