InkHighlight constructor

InkHighlight({
  1. required MaterialInkController controller,
  2. required RenderBox referenceBox,
  3. required Color color,
  4. required TextDirection textDirection,
  5. BoxShape shape = BoxShape.rectangle,
  6. double? radius,
  7. BorderRadius? borderRadius,
  8. ShapeBorder? customBorder,
  9. RectCallback? rectCallback,
  10. VoidCallback? onRemoved,
  11. 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 super.controller,
  required super.referenceBox,
  required super.color,
  required TextDirection textDirection,
  BoxShape shape = BoxShape.rectangle,
  double? radius,
  BorderRadius? borderRadius,
  super.customBorder,
  RectCallback? rectCallback,
  super.onRemoved,
  Duration fadeDuration = _kDefaultHighlightFadeDuration,
}) : _shape = shape,
     _radius = radius,
     _borderRadius = borderRadius ?? BorderRadius.zero,

     _textDirection = textDirection,
     _rectCallback = rectCallback {
  _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);
}