paint method
void
paint(
- Canvas canvas,
- Rect rect, {
- double? gapStart,
- double gapExtent = 0.0,
- double gapPercentage = 0.0,
- TextDirection? textDirection,
override
Paint this input border on canvas
.
The rect
parameter bounds the InputDecorator's container.
The additional gap
parameters reflect the state of the InputDecorator's
floating label. When an input decorator gains the focus, its label
animates upwards, to make room for the input child. The gapStart
and
gapExtent
parameters define a floating label width interval, and
gapPercentage
defines the animation's progress (0.0 to 1.0).
Implementation
@override
void paint(
Canvas canvas,
Rect rect, {
double? gapStart,
double gapExtent = 0.0,
double gapPercentage = 0.0,
TextDirection? textDirection,
}) {
assert(gapPercentage >= 0.0 && gapPercentage <= 1.0);
assert(_cornersAreCircular(borderRadius!));
final RRect outer = borderRadius!.toRRect(rect);
final RRect center = outer.deflate(borderSide.width);
final shadowPaint = Paint();
final shaderRect = rect.deflate(borderSide.width);
shadowPaint
..maskFilter = MaskFilter.blur(BlurStyle.normal, 2 + borderSide.width)
..shader = LinearGradient(
begin: FractionalOffset.topCenter,
end: FractionalOffset.bottomCenter,
colors: [
AppColors.darkShadowColor,
AppColors.lightShadowColor,
],
stops: const [
0,
1
]).createShader(shaderRect);
canvas.save();
canvas.clipRRect(center);
canvas.drawPath(
_calculateShadowPath(center, 5 - borderSide.width), shadowPaint);
canvas.restore();
}