InkSplash constructor Null safety

InkSplash(
  1. {required MaterialInkController controller,
  2. required RenderBox referenceBox,
  3. required TextDirection textDirection,
  4. Offset? position,
  5. required Color color,
  6. bool containedInkWell = false,
  7. RectCallback? rectCallback,
  8. BorderRadius? borderRadius,
  9. ShapeBorder? customBorder,
  10. double? radius,
  11. VoidCallback? onRemoved}
)

Begin a splash, centered at position relative to referenceBox.

The controller argument is typically obtained via Material.of(context).

If containedInkWell is true, then the splash will be sized to fit the well rectangle, then clipped to it when drawn. The well rectangle is the box returned by rectCallback, if provided, or otherwise is the bounds of the referenceBox.

If containedInkWell is false, then rectCallback should be null. The ink splash is clipped only to the edges of the Material. This is the default.

When the splash is removed, onRemoved will be called.

Implementation

InkSplash({
  required MaterialInkController controller,
  required super.referenceBox,
  required TextDirection textDirection,
  Offset? position,
  required Color color,
  bool containedInkWell = false,
  RectCallback? rectCallback,
  BorderRadius? borderRadius,
  ShapeBorder? customBorder,
  double? radius,
  super.onRemoved,
}) : assert(textDirection != null),
     _position = position,
     _borderRadius = borderRadius ?? BorderRadius.zero,
     _customBorder = customBorder,
     _targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position!),
     _clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
     _repositionToReferenceBox = !containedInkWell,
     _textDirection = textDirection,
     super(controller: controller, color: color) {
  assert(_borderRadius != null);
  _radiusController = AnimationController(duration: _kUnconfirmedSplashDuration, vsync: controller.vsync)
    ..addListener(controller.markNeedsPaint)
    ..forward();
  _radius = _radiusController.drive(Tween<double>(
    begin: _kSplashInitialSize,
    end: _targetRadius,
  ));
  _alphaController = AnimationController(duration: _kSplashFadeDuration, vsync: controller.vsync)
    ..addListener(controller.markNeedsPaint)
    ..addStatusListener(_handleAlphaStatusChanged);
  _alpha = _alphaController!.drive(IntTween(
    begin: color.alpha,
    end: 0,
  ));

  controller.addInkFeature(this);
}