InkHighlight constructor Null safety
- {required MaterialInkController controller,
- required RenderBox referenceBox,
- required Color color,
- required TextDirection textDirection,
- BoxShape shape = BoxShape.rectangle,
- double? radius,
- BorderRadius? borderRadius,
- ShapeBorder? customBorder,
- RectCallback? rectCallback,
- VoidCallback? onRemoved,
- Duration fadeDuration = _kDefaultHighlightFadeDuration}
Begin a highlight animation.
The controller
argument is typically obtained via
Material.of(context)
.
If a rectCallback
is given, then it provides the highlight rectangle,
otherwise, the highlight rectangle is coincident with the referenceBox.
When the highlight is removed, onRemoved
will be called.
Implementation
InkHighlight({
required MaterialInkController controller,
required super.referenceBox,
required Color color,
required TextDirection textDirection,
BoxShape shape = BoxShape.rectangle,
double? radius,
BorderRadius? borderRadius,
ShapeBorder? customBorder,
RectCallback? rectCallback,
super.onRemoved,
Duration fadeDuration = _kDefaultHighlightFadeDuration,
}) : assert(color != null),
assert(shape != null),
assert(textDirection != null),
assert(fadeDuration != null),
_shape = shape,
_radius = radius,
_borderRadius = borderRadius ?? BorderRadius.zero,
_customBorder = customBorder,
_textDirection = textDirection,
_rectCallback = rectCallback,
super(controller: controller, color: color) {
_alphaController = AnimationController(duration: fadeDuration, vsync: controller.vsync)
..addListener(controller.markNeedsPaint)
..addStatusListener(_handleAlphaStatusChanged)
..forward();
_alpha = _alphaController.drive(IntTween(
begin: 0,
end: color.alpha,
));
controller.addInkFeature(this);
}