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 textDirection = Directionality.of(context);
context.canvas
..saveContext()
..clipPath()
..applyShader(
PdfShading(
context.document,
shadingType: PdfShadingType.axial,
boundingBox: box,
function: PdfBaseFunction.colorsAndStops(
context.document,
colors,
stops,
),
start: begin.resolve(textDirection).withinRect(box),
end: end.resolve(textDirection).withinRect(box),
extendStart: true,
extendEnd: true,
),
)
..restoreContext();
}