InkRipple constructor

InkRipple({@required MaterialInkController controller, @required RenderBox referenceBox, @required Offset position, @required Color color, @required TextDirection textDirection, bool containedInkWell: false, RectCallback rectCallback, BorderRadius borderRadius, ShapeBorder customBorder, double radius, VoidCallback onRemoved })

Begin a ripple, centered at position relative to referenceBox.

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

If containedInkWell is true, then the ripple 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 ripple is clipped only to the edges of the Material. This is the default.

When the ripple is removed, onRemoved will be called.

Implementation

InkRipple({
  @required MaterialInkController controller,
  @required RenderBox referenceBox,
  @required Offset position,
  @required Color color,
  @required TextDirection textDirection,
  bool containedInkWell = false,
  RectCallback rectCallback,
  BorderRadius borderRadius,
  ShapeBorder customBorder,
  double radius,
  VoidCallback onRemoved,
}) : assert(color != null),
     assert(position != null),
     assert(textDirection != null),
     _position = position,
     _borderRadius = borderRadius ?? BorderRadius.zero,
     _customBorder = customBorder,
     _textDirection = textDirection,
     _targetRadius = radius ?? _getTargetRadius(referenceBox, containedInkWell, rectCallback, position),
     _clipCallback = _getClipCallback(referenceBox, containedInkWell, rectCallback),
     super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved)
{
  assert(_borderRadius != null);

  // Immediately begin fading-in the initial splash.
  _fadeInController = AnimationController(duration: _kFadeInDuration, vsync: controller.vsync)
    ..addListener(controller.markNeedsPaint)
    ..forward();
  _fadeIn = _fadeInController.drive(IntTween(
    begin: 0,
    end: color.alpha,
  ));

  // Controls the splash radius and its center. Starts upon confirm.
  _radiusController = AnimationController(duration: _kUnconfirmedRippleDuration, vsync: controller.vsync)
    ..addListener(controller.markNeedsPaint)
    ..forward();
   // Initial splash diameter is 60% of the target diameter, final
   // diameter is 10dps larger than the target diameter.
  _radius = _radiusController.drive(
    Tween<double>(
      begin: _targetRadius * 0.30,
      end: _targetRadius + 5.0,
    ).chain(_easeCurveTween),
  );

  // Controls the splash radius and its center. Starts upon confirm however its
  // Interval delays changes until the radius expansion has completed.
  _fadeOutController = AnimationController(duration: _kFadeOutDuration, vsync: controller.vsync)
    ..addListener(controller.markNeedsPaint)
    ..addStatusListener(_handleAlphaStatusChanged);
  _fadeOut = _fadeOutController.drive(
    IntTween(
      begin: color.alpha,
      end: 0,
    ).chain(_fadeOutIntervalTween),
  );

  controller.addInkFeature(this);
}