InkHighlight constructor Null safety

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 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);
}